Well, I know we can hide order by column from select statement by using temp tables. Just wondering how to do the same without using temp tables?
As the db I'm working is so huge, adding temp tables impact query performance a lot.
My Query is something like following:
SELECT DISTINCT
Col1,
MAX(Col2),
MAX(Col3),
Col4
FROM
Table1
Group By
Col4,
Col1
Order By
Col4
Now all i want is to get rid of Col4 from Output without using temp tables. Can't even do that using inner query. Thanks.
If your Col4 is computed/derived and it has to be in original select, you may simple make an outer query:
SELECT G.Col1, G.C2, G.C3 from
(SELECT DISTINCT
Col1,
MAX(Col2) AS C2,
MAX(Col3) AS C3,
Col4
FROM
Table1
Group By
Col4,
Col1
Order By
Col4) AS G
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With