select *
from table a
where not exists(select 1 from talbe where no_good = a.no_good and gno_goods < a.gno_goods)
from table a
where not exists(select 1 from talbe where no_good = a.no_good and gno_goods < a.gno_goods)
解决方案 »
- SELECT COUN(*) FROM User WHERE Name= "%hi%" OR Email = "%hi%" AND City=1跟(Name= "%hi%" OR Email = "%hi%")AND City=1结果不一样?
- SQL server不存在或拒绝访问
- 超级简单问题 sql 2005 express edition beta 2 如何建一个数据库?100分送上
- SqlServer怎么区分全角和半角?
- 求一条,SQL查询语句
- 关于行列转化的问题,看了很多经典的。 但是我还是不懂怎么弄我的这个。。
- 新手请教个关于SQL分组排序的问题啊
- access改为sql以后关于同时插入多个表中数据的疑问
- 大家帮帮我,请教数据库复制问题
- 谁能帮帮我?
- 存储过程 创建数据库
- 初学者的问题,关于存储过程,再送50分!进者有分。
declare @t table(id int,name varchar(18))
insert @t
select 1,'121212' union all
select 2,'121212' union all
select 3,'121211'
select *
from @t a
where not exists (
select 1
from @t where name = a.name and id < a.id) /*id name
----------- ------------------
1 121212
3 121211*/
insert into @t select '20342899','9111222333447','美术高考名师作品临摹挂图--素描头像 0'
union all select '20342900','9111222333447','美术高考名师作品临摹挂图--人物速写 0'
union all select '20486140','9111222333447','电脑2005增刊--网络时尚生活一本通(附光盘) 0'
union all select '20201694','9780803302006','初级韩国语会话(上册)1-3课--磁带 0'
union all select '20201725','9780803302006','初级韩国语会话(下册)7-9课--磁带 0 0'
union all select '20202164','9780803302006','初级韩国语会话(下册)10-11课--磁带 0'
union all select '20159132','9780995000100','新编儿童英语入门(3)磁带(二盘) 0'
union all select '20159133','9780995000100','新编儿童英语入门(1)磁带 0'--查询
select * from @t A
where not exists (select 1 from @t B where no_goods=A.no_goods and
gno_goods<A.gno_goods
)
--结果
/*
gno_goods no_goods col_other
-------------------- -------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
20342899 9111222333447 美术高考名师作品临摹挂图--素描头像 0
20201694 9780803302006 初级韩国语会话(上册)1-3课--磁带 0
20159132 9780995000100 新编儿童英语入门(3)磁带(二盘) 0(所影响的行数为 3 行)
*/
create table t (gno_goods varchar(20),no_goods varchar(20),col_other varchar(200))
insert into t select '20342899','9111222333447','美术高考名师作品临摹挂图--素描头像0'
union all select '20342900','9111222333447','美术高考名师作品临摹挂图--人物速写0'
union all select '20486140','9111222333447','电脑2005增刊--网络时尚生活一本通(附光盘)0'
union all select '20201694','9780803302006','初级韩国语会话(上册)1-3课--磁带0'
union all select '20201725','9780803302006','初级韩国语会话(下册)7-9课--磁带00'
union all select '20202164','9780803302006','初级韩国语会话(下册)10-11课--磁带0'
union all select '20159132','9780995000100','新编儿童英语入门(3)磁带(二盘)0'
union all select '20159133','9780995000100','新编儿童英语入门(1)磁带0'select * from tdelete b from t a,t b where a.no_goods=b.no_goods and a.gno_goods<b.gno_goods
select * from syb_zdigene where gno_goods in
(
select gno_goods from
(select min(gno_goods) gno_goods,no_goods from syb_zdigene group by no_goods ) nnn,
(select no_goods from syb_zdigene group by no_goods having count(gno_goods)>1) mmm
where nnn.no_goods=mmm.no_goods
) order by no_goods