这个SQL语句该怎么写? select * from table1 where id in ('001','004') 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select * from table1 aa where ITM=(select min( ITM) from table1 where g=aa.g) select * from table1 where id in(select min(id) as id from table1 group by g) select * from table1 aa where id=(select top 1 id from table1 where g=aa.g)select * from table1 aa where id=(select min(id) from table1 where g=aa.g) select a.*from table1 a join ( select min(id) as mi,g from table1 group by g ) b on a.id=b.mi 比如说:表结构为: ID ID1 ID2 ITM QTY G 001 A0 B1 1 2 1 001 A0 B1 2 4 1 002 A1 B1 3 6 1 003 A0 B1 1 1 2 004 A1 B1 2 4 2我想得到: ID ID1 ID2 ITM QTY G 001 A0 B1 1 2 1 003 A0 B1 1 1 2 還是select * from table1 where id in ('001','003') pengdali(大力 V3.0) 是对的 现在问题已经很简单了,你在表中建一个主键(自动加1),然后安pengdali(大力 V3.0) 的方法实现就搞定了 再增加一个字段(自动加1),你什么都不需要管呀,insert、update都不用你管,会有什么问题? sql server2005附加2005的数据库出现如下问题 如何得到排序语句后的首条记录? 设计表结构,帮分析问题?? 为什么我的 like条件没有生效 smalldeer(晓露)进来一下 触发器问题 指定单表备份sql代码执行出错! 计算问题 高分求教:有重复值怎么办,急! 这个备份语句哪错了? 查询条件很多的存储过程,怎样分页返回记录集? 各位老大,怎样将原来的存储过程替换掉!!把它覆盖掉可以吗?
select * from table1 aa where id=(select min(id) from table1 where g=aa.g)
from table1 a join
( select min(id) as mi,g
from table1
group by g
) b
on a.id=b.mi
表结构为:
ID ID1 ID2 ITM QTY G
001 A0 B1 1 2 1
001 A0 B1 2 4 1
002 A1 B1 3 6 1
003 A0 B1 1 1 2
004 A1 B1 2 4 2
我想得到:
ID ID1 ID2 ITM QTY G
001 A0 B1 1 2 1
003 A0 B1 1 1 2
select * from table1 where id in ('001','003')