>>USE at18; >>IF OBJECT_ID('tempdb.dbo.#Table1', 'U') IS NOT NULL >> DROP TABLE #Table1; >> >>CREATE TABLE #Table1 >>( >>code VARCHAR(50), >> names VARCHAR(50), >> country VARCHAR(50), >> qty int >>) >> >>INSERT INTO #table1 VALUES (1104,'ERIC','Holland',45) >>INSERT INTO #table1 VALUES (1105,'Boris','Bulgaria',50) >>INSERT INTO #table1 VALUES (1106,'Anil','India',75) >>INSERT INTO #table1 VALUES (1107,'Cetin','Turkey',65) >>INSERT INTO #table1 VALUES (1105,'Boris','Bulgaria',40) >>INSERT INTO #table1 VALUES (1104,'ERIC','Holland',65) >>INSERT INTO #table1 VALUES (1107,'Cetin','Turkey',85) >>INSERT INTO #table1 VALUES (1106,'Anil','India',25) >> >>select * from #table1 order by code >> >>select code,max(names)as names,max(country)as country,sum(qty)as qty >>from #Table1 >>group by code >>order by code >>>>
>select code,names,country,sum(qty)as qty >from #Table1 >group by code,names,country >order by code >Thanks sir Cetin Basoz for helping but I do not want to use more than one column in group by clause.