我们是五月的花海 , 用青春拥|

兴想事成

园龄:12年10个月粉丝:25关注:97

[sql查询] 重复数据只取一条

SELECT * FROM  tab_init
WHERE id IN 
( 
--根据Data分类获取数据最大ID列表 
select max(id) from tab_init
group by a,b
)

 先找出重复数据的 最大的Id ( group by 后面可跟多列, 根据规则找到重复数据), 取出 id 最大或最小的 Id, 然后使用 in查询,就可以得到不重复的数据

配合 With .. As () 非常方便

复制代码
 --tab_jcxh_CertificateInfoAbility_New导入最新数据
 go

 with  tab_init
  
 as  
   (
      select ROW_NUMBER() over (order by OperateTime) as Id,* from  [Person].tab_jcxh_CertificateInfoAbility
   )

  insert into [Person].tab_jcxh_CertificateInfoAbility_New(IndexId,CertificateNumber,ItemCode,ItemName,CertificateDeadline,zzType,IsOperate,OperateTime)
 SELECT IndexId,CertificateNumber,ItemCode,ItemName,CertificateDeadline,zzType,IsOperate,OperateTime  FROM  tab_init
WHERE id IN 
( 
--根据Data分类获取数据最大ID列表 
select max(id) from tab_init
group by CertificateNumber
)
复制代码

 

posted @   兴想事成  阅读(1166)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 Good-bye My Loneliness ZARD
  2. 2 Say OK Vanessa Hudgens
  3. 3 All The Love In The World The Corrs
  4. 4 Adesso E Fortuna ~炎と永遠~ 加藤いづみ
Say OK - Vanessa Hudgens
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

作词 : BIRGISSON, ARNTHOR/KOTECHA, SAVAN

作曲 : Savan Kotecha/Arnthor Birgisson

Vanessa Hudgens - Say OK

Album: V

You are fine

You are fine

You are fine

You are fine

You are sweet

But I'm still a bit naive with my heart

When you're close I don't breathe

I can't find the words to speak

I feel sparks

But I don't wanna be into you

If you are not looking for true love, oh oh

No I don't wanna start seeing you

If I can't be your only one

So tell me when it's not alright

When it's not ok

Will you try to make me feel better?

Will you say alright? (say alright)

Will you say ok? (Say ok)

Will you stick with me through whatever?

Or run away

(Say that it's gonna be alright)

(That it's gonna be ok)

Say OK

When you call I don't know

If I should pick up the phone every time

I'm not like all my friends

Who keep calling up the boys, I'm so shy

But I don't wanna be into you

If you don't treat me the right way

See I can only start seeing you

If you can make my heart feel safe (feel safe)

When it's not alright

When it's not ok

Will you try to make me feel better?

Will you say alright? (say alright)

Will you say ok? (Say ok)

Will you stick with me through whatever?

Or run away

(Say that it's gonna be alright)

(That it's gonna be ok)

(Don't run away, don't run away)

Let me know if it's gonna be you

Boy, you've got some things to prove

Let me know that you'll keep me safe

I don't want you to run away so

Let me know that you'll call on time

Let me know that you won't be shy

Will you wipe my tears away

Will you hold me closer

When it's not alright

When it's not ok

Will you try to make me feel better

Will you say alright? (say alright)

Will you say ok? (Say ok)

Will you stick with me through whatever?

Or run away

(Say that it's gonna be alright)

(That it's gonna be ok)

Say OK

(Don't run away, don't run away)

(Say that it's gonna be alright)

(That it's gonna be ok)

(Don't run away)

Will you say OK

(Say that it's gonna be alright)

(That it's gonna be ok)

(Don't run away)

You are fine

You are fine