Andrew Beller (andrew.beller (AT) salliemae (DOT) com) writes:
Quote:
I have a query where I need to return rows but only if one columns first
two characters are unique. I have this currently which works, but want
to (and was told I should) do this without using MAX just so I can use
the Group By. Here is my query. Can somone help me find the correct
way to only return unique rows when the MajorVersion column is unique. |
I'm afraid that I'm a little lost. What you do you mean with "do this
without using MAX just so I can use the Group By". You are using GROUP BY,
aren't you? MAX does not prevent you to use GROUP BY, rather you typically
need GROUP BY when you have MAX.
Nor do I really understand what you mean with "if one columns first
two characters are unique". I would interpret this as if you have the rows
Col1 Col2
Albert 2
Allan 8
Victoria 8
Viscount 10
Blenda 12
Hugo 12
Hubert 19
Peter 1
You should return the rows with Blenda and Peter. But that does not match
your query which you say is working.
Could you clarify?
--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx