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 |
|
evanburen
Posting Yak Master
167 Posts |
Posted - 2011-03-01 : 21:03:45
|
| How I can add ID to this SELECT statement but not GROUP BY this value? Every ID is unique so it never returns any records. SELECT ID, SSN, COUNT(*) AS VACount FROM v_MyVAApps GROUP BY ID, SSN HAVING COUNT(*) > 1 ORDER BY SSN |
|
|
evanburen
Posting Yak Master
167 Posts |
Posted - 2011-03-01 : 21:31:45
|
| HiThis works for meSELECT MAX(ID),SSN, COUNT(*) AS VACountFROM v_MyVAAppsGROUP BY SSNHAVING COUNT(*) > 1 ORDER BY SSN |
 |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-03-02 : 22:26:12
|
| Please post real DDL. Learn to use ISO-11179 rules for the data element names, avoid needless dialect and use ISO-8601 temporal formats, codes and so forth. People cannot read your mind, so post your code and clear specs if you really want help.Rows are not records. What you asked makes no sense. What value for your vague generic "id" did you expect to see? --CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
|
|
|