Wednesday, March 21, 2012

Multiple WHEREs in a query?

I want a query ro select the number of wins and the number of games played for a team. The pertinent columns are all in the same table and I was trying to get the information all in one query. Is something like this possible?
SELECT COUNT(*) AS Wins
FROM tbl_Schedule
WHERE Winner = 'IND'
SELECT COUNT(*) AS GamesPlayed
FROM tbl_Schedule
WHERE HomeID = 'IND' OR VisitorID = 'IND'
How would I merge the two, or can I even do that?SELECT
'Wins' = (SELECT COUNT(*) FROM tbl_Schedule WHERE Winner = 'IND'),
'GamesPlayed' = (SELECT COUNT(*) AS GamesPlayed FROM tbl_Schedule WHERE HomeID = 'IND' OR VisitorID = 'IND')|||Oh, very cool. I had no idea you could format them like that. Thanks for the help!

No comments:

Post a Comment