Link to home
Start Free TrialLog in
Avatar of lcor
lcor

asked on

Derived Attributes

How do derived attributes work?  I would like to see a typical SQL example, if possible.
Avatar of BillAn1
BillAn1

homework????
I'm guessing from your prior questions that you're a professional, so here's an typical example if a table already has numeric columns named TotalSales and TotalCosts:

ALTER TABLE TableA ADD GrossProfit as TotalSales - TotalCosts

[If I'm wrong, and you are asking for homework, then my answer is: I used to have a Chevy Attribute that I would derive to work, and it worked by pushing the gas peddle.  :) ]
ASKER CERTIFIED SOLUTION
Avatar of jdlambert1
jdlambert1
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lcor

ASKER

Gee, guys, I hope I didn't offend anyone with my question.  I was just trying to be specific about what I was looking for.

Anyway, would the ALTER SQL command be included in script that creates the schema?
Sorry, didn't notice the follow up question until now.

You can add an ALTER TABLE command to a longer script, or, if you're creating the table, you can define the derived column in the CREATE TABLE command:

CREATE TABLE TableA(Col1 int, Col2 int, Col3 as Col1 + Col2)

[I don't think anyone was offended. And I was happy to get to use my "derive to work" joke. :) ]