34,588
社区成员
发帖
与我相关
我的任务
分享
select 编号 from tb a where a.编号 not in (select 编号 from tb a where a.流程=1)
select 编号 from t group by 编号 having count(编号)<2
select 编号 from t
where 编号 not in
(select 编号 from t
where 流程=1)
select 编号 from tab
where 编号 not in (select 编号 from tab where 流程=1)
group by 编号
select 编号,流程 from A where 流程<>1
/*if object_id('H') is not null drop table H
create table H(num int,data int)
insert H
select 1, 0 union all
select 2, 0 union all
select 2, 1 union all
select 3, 0 union all
select 3, 1 union all
select 4, 0 */
select num from H group by num having max(data)=0
if object_id('tb') IS NOT NULL
DROP TABLE tb
go
create table tb
(bh int,
lc int
)
insert into tb
select 1,0
union all
select 2,0
union all
select 2,1
union all
select 3,0
union all
select 3,1
GO
select * from tb where bh not in( select bh from tb where lc=1)
if object_id('tb') IS NOT NULL
--> 数据库版本:
--> Microsoft SQL Server 2008 (RTM) - 10.0.1600.22
--> 测试数据:[TB]
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[TB]')
AND type in (N'U'))
DROP TABLE [TB]
GO
---->建表
create table [TB]([编号] int,[流程] int)
insert [TB]
select 1,0 union all
select 2,0 union all
select 2,1 union all
select 3,0 union all
select 3,1
GO
--> 查询结果
SELECT a.* FROM [TB] a join (select distinct 编号 from TB) b
on a.编号 = b.编号 and a.编号<=1
--> 删除表格
--DROP TABLE [TB]
select 编号,流程 from A a1
where not exists (
select 1 from a
where 编号 = a1.编号
and 流程=1
)