I would like to select distinct on some column, and get other information from other column (not distinct):SELECT A,B,DISTINCT C FROM TABLEI know that SQL accept only distinct just after "select"Please help me!Table "TLQuyDoi"cifno ten DCQuyDoi1 a 101 b 102 s 9I like to get only distinct on (cifno and DCQuyDoi) , besides get the value of "Ten"The resuls I hope like thiscifno ten DCQuyDoi1 a 102 s 9Here is my codecreate table #KetQua (cifno varchar(10),SumDCQuyDoi float) Insert into #KetQuaSelect cifno,sum(DCQuyDoi)From TLQuyDoi tGroup by cifnoHaving sum(DCQuyDoi) >= @GiaTriOrder by cifno,sum(DCQuyDoi)Select distinct k.cifno,t.ten,k.SumDCQuyDoiFrom #KetQua k,TLQuyDoi tWhere k.cifno=t.cifno Order by k.SumDCQuyDoi desc,k.cifno ascdrop table #KetQua