April 3, 2011 at 6:55 pm
when I run this query:
Use adventureworks2008r2;go
select SUM(totaldue) as totalofallorders
,SUM(distinct totaldue) as totalofdistincttotaldue
,(SUM(totaldue)- SUM(distinct totaldue) as dif
from sales.SalesOrderHeader;
I get this error:
Msg 156, Level 15, State 1, Line 8
Incorrect syntax near the keyword 'as'.
The above query runs when the line with the subtract operator is removed.
Why won't it run when I try to subtract one computed column from another?
April 3, 2011 at 9:22 pm
You missed a bracket just before "as diff"
select SUM(totaldue) as totalofallorders
,SUM(distinct totaldue) as totalofdistincttotaldue
,(SUM(totaldue)- SUM(distinct totaldue) ) as dif
from sales.SalesOrderHeader;
April 3, 2011 at 9:51 pm
wonderful! Thank you.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply