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.
Author |
Topic |
shajimanjeri
Posting Yak Master
179 Posts |
Posted - 2006-11-09 : 12:38:13
|
Hi all,I have two table,one is C20_Messages and second one is Ports.Here want to get the count of records if the status of Ports_ID = 1Then I wrote the query like this, but showing errorSELECT C20_messages.Port_ID, Ports.status, COUNT(C20_messages.*) AS Sum FROM C20_messages, Ports where datepart(year,C20_messages.Msg_Time) = '2006' and C20_Messages.Port_ID = Ports.ID and Ports.Status = 1 GROUP BY C20_Messages.Port_IDpls help meshaji |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-11-09 : 13:08:58
|
If you want to have Ports.status in the select list you'll have to put it in your GROUP BY. Otherwise if you don't really need it then remove it from the select list. And you can just use COUNT(*). |
|
|
|
|
|