我已经得到如下列表:
COL1 COL2 COL3
176 138 1001
176 139 1001
177 141 1001
177 143 1001
177 144 1001
178 155 1001
178 156 1001
怎么得到以下(从每组中得到第一条)
COL1 COL2 COL3
176 138 1001
177 141 1001
178 155 1001
谢谢!
COL1 COL2 COL3
176 138 1001
176 139 1001
177 141 1001
177 143 1001
177 144 1001
178 155 1001
178 156 1001
怎么得到以下(从每组中得到第一条)
COL1 COL2 COL3
176 138 1001
177 141 1001
178 155 1001
谢谢!
Select col1, first(col2), first(col3) from table group by col1
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)
http://feiyun0112.cnblogs.com/
declare @t table(col1 decimal(9,0),col2 decimal(9,0),col3 decimal(9,0))
insert into @t(col1,col2,col3)values(176,138,1001)
insert into @t(col1,col2,col3)values(176,139,1001)
insert into @t(col1,col2,col3)values(177,141,1001)
insert into @t(col1,col2,col3)values(177,143,1001)
insert into @t(col1,col2,col3)values(177,144,1001)
insert into @t(col1,col2,col3)values(178,155,1001)
insert into @t(col1,col2,col3)values(178,156,1001)select * from @t
where Convert(varchar(9),col1)+';'+Convert(varchar(9),col2) in(
select Convert(varchar(9),col1)+';'+Convert(varchar(9),min(col2)) as col2 from @t group by col1)
select first(cardid) from ccard服务器: 消息 195,级别 15,状态 10,行 1
'first' 不是可以识别的 函数名。SQL SERVER不支持FIRST
对于不支持 FIRST 的数据库引擎:Select col1, col2, col3 from table Where Col1 In (Select Distinct Col1 From Table)