why can't I do this?
why can't I do this?
(OP)
Why is this illegal and how can I fix it? Thanks.
SELECT COUNT(*) AS NumberOfHistory
FROM Enrolls
WHERE COURSENUM = 405;
SELECT COUNT(*) AS NumberOfScience
FROM Enrolls
WHERE COURSENUM = 605;
SELECT COUNT(*) AS NumberOfHistory
FROM Enrolls
WHERE COURSENUM = 405;
SELECT COUNT(*) AS NumberOfScience
FROM Enrolls
WHERE COURSENUM = 605;
RE: why can't I do this?
Try counting your table key (whatever its name is)
eg
SELECT COUNT(table_key) AS NumberOfHistory
FROM Enrolls
WHERE COURSENUM = 405;
Or are you wanting two columns then
select sum( case when coursenum = 605 then 1 else 0 end ) as NumOfSci,
sum( case when coursenum = 405 then 1 else 0 end ) as NumOfHist
FROM Enrolls
Ian
RE: why can't I do this?
CODE
FROM Enrolls
WHERE COURSENUM = 405
UNION
SELECT "Science" AS Cource COUNT(*) AS Number
FROM Enrolls
WHERE COURSENUM = 605;
Or more efficiently:
CODE
FROM Enrolls
WHERE COURSENUM IN (405,605)
GROUP BY COURSENUM
Without knowing a little more about what you want, what error you're getting and what system you're running, it's difficult to provide you with the exact answer you need!
hth
Ben
----------------------------------------------
Ben O'Hara www.RobotParade.co.uk
RE: why can't I do this?
it isn't, and you don't have to
r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
RE: why can't I do this?
I agree with r937. If it's "illegal", there must be an error message you can post?
Ever notice how fast Windows runs? Me neither.
RE: why can't I do this?
SELECT COURSENUM,COUNT(*) AS NumberOfScience
FROM Enrolls
WHERE COURSENUM = 605;