Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

SQL: How to ALTER TABLE with an aggregate function (derived, calculated fields)?

I have this assignment where I need to add columns to a table in the SQL Command Line Interface of Oracle 10g XE.

The database is for an air charter service and the table is CHARTER.

I need to add an attribute called CHAR_FLT_CHG_HR, which is copied from the MODEL table using an attribute called MOD_CHG_MILE.

I feel like it ought to be something like:

ALTER TABLE charter

ADD char_flt_chg_hr AS (

But that is as far as I get. How do I reference another table when I use the ALTER TABLE statement?

Further problems are as such:

CHAR_FLT_CHG is a new column that is char_hours_flown x char_flt_chg_hr, but I am unclear about how to use an aggregate function within an ALTER TABLE statement.

I can't test it out now because I don't have the char_flt_chg_hr column created yet, but it seems that it might be:

ALTER TABLE charter

ADD char_flt_chg AS (char_hours_flown x char_flt_chg_hr)

or something along those lines?

And further still, there is one that wants me to calculate a charge with tax, CHAR_TAX_CHG.

Would this be something like...?

ALTER TABLE charter

ADD char_tax_chg AS (char_flt_chg x .08)

.

Update:

.

For reference, the problem in question is #35 from here:

http://books.google.com/books?id=_wmNpjHhOoQC&pg=P...

.

2 Answers

Relevance
  • 9 years ago

    Are you sure the intent is to both add and populate the column in a single query? Normally, it's a two-step process.

  • 4 years ago

    modify table tbl_Attendance upload COLUMN modern-day date; "date" is a kind in maximum databases and won't be able for use as a column call in them. you want to grant a column call. I used "modern-day" (as in "change into modern-day"), because it really is a table about attendance. Use even with you want. also, i do not recognize Delphi, so i do not recognize in case you want to comprise the ending semicolon or not. part note: some people use uppercase for kinds. that is a coding decision, so as that is as a lot as you or your institution.

Still have questions? Get your answers by asking now.