个人收藏的SQL语句【T-SQL】

----查询a表中有b表中没有的数据

select distinct a.科目编码,a.科目名称,'',1 from [2007] a left outer join account b
on a.科目编码=b.科目编码
where b.科目编码 is null

--凭证中有科目代码,科目表没有的
select distinct a.科目代码,a.科目名称,left(a.科目代码,1)as 科目性质,case left(a.科目代码,1) when 1 then 1
when 2 then -1
when 3 then -1
when 4 then 1
when 5 then -1
else 1
end as 借贷方向,0 as 往来核算  from voucher a
left outer join account b
on a.科目代码=b.科目代码
and b.科目代码 is null

 

--查询重复数据
select * from aaa where col001 in(select col001 from aaa group by col001 having count(*)>1 )

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值