Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 computed correlated subquery

Author  Topic 

zippy
Yak Posting Veteran

69 Posts

Posted - 2001-10-15 : 17:53:56
another questiong on subqueries.
Is it possible to do a computation on values from a subquery,
for example I am using the following code (simplified somewhat):

ISNULL((SELECT TOP 1 SUM(sub.TotalLoved) AS TotalLoved
FROM tblLoved sub INNER JOIN
tblPeople sub2 ON sub.PersonID = sub2.PersonID
GROUP BY sub.PersonID, sub.DayLoved
HAVING sub.PersonID = qry.PersonID
ORDER BY sub.PersonID, sub.DayLoved), 0) AS Thursday,
ISNULL((SELECT TOP 1 SUM(sub.TotalLoved) AS TotalLoved
FROM tblLoved sub INNER JOIN
tblPeople sub2 ON sub.PersonID = sub2.PersonID
GROUP BY sub.PersonID, sub.DayLoved
HAVING sub.PersonID = qry.PersonID
ORDER BY sub.PersonID, sub.DayLoved), 0) AS Friday

I know want to add the coloums Thursday and Friday together to make a total column,
is that possible?
I have tried going
Total AS Thursday+Friday
but that does not seem to work

Thanks

Check out the worlds fastest computers at http://www.ocgurus.com
   

- Advertisement -