SQL to return one row for each distinct value of a column (do not mind which row) -
SQL to return one row for each distinct value of a column (do not mind which row) -
i have table column named x. x contains number 0 99. there duplicates (e.g. 0 there multiple times! )
now need query gives of rows 0,1,2,3...99 meaning 100 results @ 1 query, don't care of x==0 , x==1 ... get, 1 of them!
is there such thing in sql?
select distinct x your_table
to finish record can grouping x column. have tell db of duplicate values of other columns want.
select x, min(y) y your_table grouping x if build grouping x value distinct. other columns need called aggregate function illustration min(). tells db pick minimum y of every x group.
sql
Comments
Post a Comment