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 |
|
editech
Starting Member
4 Posts |
Posted - 2006-11-14 : 12:34:56
|
| I have a table "TableA" which has field1,field2,field3. field1 | field2 | field3 | 1 | 2 | 45 | 2 | 2 | 45 | 3 | 2 | 45 | I want the the query to return the count(not counting duplicate field2 and field3 values) where Field2=2 and Field3=45 In this case I want the count to return only 1 Basically I dont want to count duplicates. Thanks in advance |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-14 : 12:49:06
|
| SELECT DISTINCT 1 from TableA WHERE Field2 = 2 AND Field3 = 45Peter LarssonHelsingborg, Sweden |
 |
|
|
editech
Starting Member
4 Posts |
Posted - 2006-11-14 : 12:58:40
|
I want the count quote: Originally posted by Peso SELECT DISTINCT 1 from TableA WHERE Field2 = 2 AND Field3 = 45Peter LarssonHelsingborg, Sweden
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-14 : 13:02:04
|
You wrote you wanted 1 back as result?quote: Originally posted by editech In this case I want the count to return only 1
SELECT Field2, Field3, COUNT(*), COUNT(DISTINT Field1) FROM TableAWHERE Field2 = 2 AND Field3 = 45Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|