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
 Development Tools
 ASP.NET
 Help writing a SQL query please!

Author  Topic 

robsbiz
Starting Member

3 Posts

Posted - 2006-03-12 : 06:06:55
I have been strugling with for hours -
I have a table with the following columns
UID(decimal) | SD(bit) | MB(bit) | TS(bit) | Total(Decimal)

I want to run a query which will return
UID, Total if SD is True AND
UID, Total if MB is True AND
UID, Total if TS is True


UID is the userID so there would be a WHERE statement
ORDERED BY Total Descending

Many thanks in advance

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2006-03-12 : 06:43:04
Is this homework?

SELECT YourTable.UID, YourTable.Total
FROM YourTable
WHERE YourTable.SD = 1 AND YourTable.MB = 1 AND YourTable.TS = 1
ORDER BY YourTable.Total DESC
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-03-12 : 09:37:51
robsbiz,

Can u provide with some data and the expected results
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2006-03-12 : 15:22:38
check BOL for the CASE statement.



-ec
Go to Top of Page
   

- Advertisement -