April 12, 2013 at 7:35 am
Hi,
I went to retrive the the maximum of one cloumn in the table meet some where criteria. I tried the folowing SQL
Select Name, Max(version) from table1 where name="Asdf";
I am unable to get the required result set which I need from above query.
Can you please tell me what is wrong with the query?
Thank you!
April 12, 2013 at 7:47 am
grasshopper26 (4/12/2013)
Hi,I went to retrive the the maximum of one cloumn in the table meet some where criteria. I tried the folowing SQL
Select Name, Max(version) from table1 where name="Asdf";
I am unable to get the required result set which I need from above query.
Can you please tell me what is wrong with the query?
Thank you!
Select Name, Max(version) from table1 where name="Asdf" group by Name;
April 12, 2013 at 7:49 am
Either of these:
SELECT Name, MAX(version) OVER(PARTITION BY Name)
FROM table1
WHERE name = 'Asdf';
SELECT Name, MAX(version)
FROM table1
WHERE name = 'Asdf'
GROUP BY Name;
Avoid doublequotes, they have a special meaning to SQL Server.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply