question

technette avatar image
technette asked

Calculated Columns

How would I add a column that would supply the number of days for the following? I originally had three separate stored procedures that returned the rows. I need to use just one for my chart. 1. DATEDIFF(DAY, GetDate(), DATEADD(day, (P.Planning_LeadTime * -1), PLO.Want_Date)) BETWEEN -10 AND -20 2. DATEDIFF(DAY, GetDate(), DATEADD(day, (P.Planning_LeadTime * -1), PLO.Want_Date)) > -20 3. DATEDIFF(DAY, GetDate(), DATEADD(day, (P.Planning_LeadTime * -1), PLO.Want_Date)) < -20
calculated-column
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

The code snippets above are predicates (they equate to either true or false) - what do you use the values of these to do?
0 Likes 0 ·

1 Answer

·
Kev Riley avatar image
Kev Riley answered
Why not use a view?
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

The view is simply a query over a table (or set of tables), so it would look like: select a, b, a+b as CalculatedColumn from Table
1 Like 1 ·
I could possibly use a view and use a stored procedure to pass in parameter and query the view. Would you happen to have a link regarding calculated columns in views?
0 Likes 0 ·
Thank you Kev, I think that I was making this more complicated than it is.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.