sql server - How to get a max value of a column in SQL? -
i want find max value of column. have following table structure:
orderid | taskid | serialno 1 | 1 | 1 1 | 1 | 2 1 | 2 | 1 1 | 2 | 2 1 | 2 | 3 2 | 1 | 1 2 | 2 | 1 2 | 2 | 2 from above table want following result every orderid , taskid, display max value:
serialno 2 3 1 2 by using max getting orderid , taskid well, not intended result. using sql server. how intended result?
select orderid, taskid, max(serialno) mytable group orderid, taskid if want max(serialno), can omit other 2 columns in select.
Comments
Post a Comment