Hello Everyone,
Can anyone know how to use order by without use of group by ?
Problem :
I have some of col in my sql query of select like where i also used some aggregate functions now i want to use one col EntryDate from my table but didn't want to use that in group by.
Example:
- SELECT ID, CONVERT(VARCHAR(15), EntryDate, 101) AS Entry_Date , NAME, SUM(PRICE) FROm MYTABLE WITH ( NOLOCK ) GROUP BY ID, NAME, CONVERT(VARCHAR(15), EntryDate, 101)
- SELECT ID, CONVERT(VARCHAR(15), EntryDate, 101) AS Entry_Date , NAME, SUM(PRICE) FROm MYTABLE WITH ( NOLOCK ) GROUP BY ID, NAME, CONVERT(VARCHAR(15), EntryDate, 101)
- ORDER BY EntryDate


Nitin SontakkeRank #264 · 9.6K reputationPosted Jul 26, 2018, 2:41 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Jul 26, 2018, 3:01 AM EDT
Jenith ThakkarRank #789 · 2.9K reputationPosted Jul 26, 2018, 12:29 AM EDT
if yes then you can try partition over by for that Like this
I hope it will helpful for you
Nitin SontakkeRank #264 · 9.6K reputationPosted Jul 26, 2018, 12:36 AM EDT
Nikunj SatasiyaRank #302 · 8.3K reputationPosted Jul 26, 2018, 12:42 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Jul 26, 2018, 1:48 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Jul 26, 2018, 2:37 AM EDT
Nikunj SatasiyaRank #302 · 8.3K reputationPosted Jul 26, 2018, 2:43 AM EDT
Nikunj SatasiyaRank #302 · 8.3K reputationPosted Jul 26, 2018, 2:48 AM EDT
Nikunj SatasiyaRank #302 · 8.3K reputationPosted Jul 26, 2018, 3:41 AM EDT