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 |
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2012-10-24 : 11:39:34
|
| I have a table called Users and want to count how many lastname of Smith are in the table.Is this correct?Count * from Users where lastname like ‘University% |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-24 : 11:47:26
|
nopeit should beSELECT COUNT(*) FROM Users WHERE lastname like ‘University% lookup books online for syntax help------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2012-10-24 : 11:59:25
|
| Thanks! |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2012-10-24 : 12:00:54
|
| One more...I want to get all users whose ages are between 15 - 20SELECT COUNT(*) from Users WHERE age between 15 and 20 Want to make sure between is correct. |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-10-24 : 12:12:06
|
| SELECT COUNT(*) from Users WHERE age between 15 and 20 The end-points are included, so this will give you anybody where age >= 15 and age <= 20, if that's what you want.JimEveryday I learn something that somebody else already knew |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2012-10-24 : 12:31:20
|
| If I have a query that says how many last names begin with S should I count them our list them? |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-10-24 : 12:44:53
|
quote: Originally posted by JJ297 I have a table called Users and want to count how many lastname of Smith are in the table.Is this correct?Count * from Users where lastname like ‘University%
Count * from Users where lastname = 'Smith'quote: Originally posted by JJ297 If I have a query that says how many last names begin with S should I count them our list them?
Umm, it's your query. Do you not know if you need a list or a count? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-24 : 12:46:08
|
quote: Originally posted by JJ297 If I have a query that says how many last names begin with S should I count them our list them?
does that mean you dont know what you want?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2012-10-24 : 12:49:59
|
Yes I know I want them both. I'm OK now. Thanks! |
 |
|
|
|
|
|