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 2005 Forums
 Transact-SQL (2005)
 TSQL simple query

Author  Topic 

Datapimp23
Starting Member

2 Posts

Posted - 2009-10-30 : 08:40:28
hey guys,

Imagine this.

Table: key reservation
columns:
ReservationID <- primary key
keyID
EmployeeID


now I want to count how much times a certain key is in this table without using the where for every keyID.

Is this possible?




senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-10-30 : 08:44:57
You mean this?

select count(keyid),keyid from table group by keyid

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-10-30 : 08:46:39
select count(keyid),EmployeeID from table group by EmployeeID

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Datapimp23
Starting Member

2 Posts

Posted - 2009-10-30 : 09:01:14
that was it,

thanks madhivanan
Go to Top of Page
   

- Advertisement -