Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I am a newbie..and here is my newbie questionI have 2 tables : table1 and table2SELECT table1.cache_type, table2.log_owner_idFROM table1, table2WHERE table1.cache_id = table2.cache_id and table2.log_owner_id=62 and table1.cache_type = "traditional"This returns 10 rows. But what I would like to do is return the total number of rows..the COUNT. I tried the following but that does not work:SELECT COUNT(*) table1.cache_type, table2.log_owner_idFROM table1, table2WHERE table1.cache_id = table2.cache_id and table2.log_owner_id=62 and table1.cache_type = "traditional"any help would be greatly appreciated! thx
DustinMichaels
Constraint Violating Yak Guru
464 Posts
Posted - 2007-03-09 : 14:29:20
Try using a group by statement.
SELECT COUNT(*) table1.cache_type, table2.log_owner_idFROM table1, table2WHERE table1.cache_id = table2.cache_id and table2.log_owner_id=62 and table1.cache_type = "traditional"GROUP BY table1.cache_type, table2.log_owner_id
DustinMichaels
Constraint Violating Yak Guru
464 Posts
Posted - 2007-03-09 : 14:30:21
Err oops I misread your post, just use COUNT(*) in the select statement.
SELECT COUNT(*)FROM table1, table2WHERE table1.cache_id = table2.cache_id and table2.log_owner_id=62 and table1.cache_type = "traditional"
dbusher
Starting Member
7 Posts
Posted - 2007-03-09 : 14:58:10
wow..thanks for the prompt response..I will give this a try.