I want to group entries in a table by just one matching colum. Here is an example of the data:
COLUM1 COLUM2 COLUM3
034 XY CV
040 FG RR
098 GT ZT
034 CC UU
034 ZT HG
098 QA BN
Now I want to group this data just by COLUM1, regardless of the values in the other colums. So that the output looks like this:
COLUM1 COLUM2 COLUM3
034 XY CV
034 ZT HG
034 CC UU
098 QA BN
098 GT ZT
040 FG RR
How can this be achieved?
答案 0 :(得分:0)
Use ORDER BY
SELECT COLUM1, COLUM2, COLUM3
FROM yourtable
ORDER BY COLUM1
答案 1 :(得分:-1)
Simlpy use
order by column1;
But if you want to use group by and order by in same query you can use
select * from (
select * from table1 order by column1) tempName
group by calumn2;
Its not efficient but its working.