Chinaunix首页 | 论坛 | 博客
  • 博客访问: 530218
  • 博文数量: 88
  • 博客积分: 2256
  • 博客等级: 大尉
  • 技术积分: 921
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-08 23:20
个人简介

积硅步,行千里

文章分类

全部博文(88)

文章存档

2019年(5)

2018年(1)

2016年(15)

2015年(23)

2013年(3)

2012年(6)

2011年(3)

2010年(22)

2009年(10)

我的朋友

分类: SQLServer

2016-03-10 16:56:16


  1. select clock_id,emp_id,card_id,sign_time,card_consume,ID
  2. from mealrecords
  3. where sign_time >='2016-02-01'


  4. select clock_id,emp_id,card_id,sign_time,card_consume
  5. from mealrecords
  6. where sign_time in (select sign_time from mealrecords group by sign_time having count(1) >= 2) and
  7. card_id in (select sign_time from mealrecords group by sign_time having count(1) >= 2)



  8. ******鏌ヨ?鏄嗗北閲嶅?娑堣垂鏁版嵁******
  9. select count(*),E.emp_id,E.card_id,E.emp_fname,E.sign_time
  10. from (
  11. SELECT A.emp_id as emp_id,A.card_id as card_id,A.emp_fname as emp_fname,B.sign_time as sign_time,C.depart_name as depart_name
  12. FROM Employee A
  13. left join mealrecords B on A.emp_id = B.emp_id
  14. left join Departs C on C.depart_id=A.depart_id
  15. where B.sign_time >= '2016-02-01' and A.link_man='鏄嗗北椤哄▉') as E
  16. group by E.emp_id,E.emp_fname,E.depart_name,E.card_id,E.sign_time having count(sign_time)>1


  17. *****鏌ヨ?鏄嗗北娑堣垂鏁版嵁鎵ц?缁撴灉*****
  18. select clock_id,emp_id,card_id,sign_time,card_consume
  19. from mealrecords
  20. where card_id='602481' and sign_time >= '2016-03-01 '

  21. *****鍒犻櫎鏄嗗北閲嶅?娑堣垂鏁版嵁******
  22. delete from mealrecords where sign_time in(
  23. select E.sign_time
  24. from Mealrecords as E
  25. left join Employee A on A.emp_id = E.emp_id
  26. where E.sign_time >= '2016-02-01' and A.link_man='鏄嗗北椤哄▉'
  27. group by E.emp_id,E.card_id,E.sign_time having count(E.sign_time)>1
  28. )
  29. and id not in
  30. (
  31. select min(E.id)
  32. from Mealrecords as E
  33. left join Employee A on A.emp_id = E.emp_id
  34. where E.sign_time >= '2016-02-01' and A.link_man='鏄嗗北椤哄▉'
  35. group by E.emp_id,E.sign_time having count(E.sign_time)>1
  36. )


  37. *******************************
  38. select min(E.id)
  39. from Mealrecords as E
  40. left join Employee A on A.emp_id = E.emp_id
  41. where E.sign_time >= '2016-02-01' and A.link_man='鏄嗗北椤哄▉'
  42. group by E.emp_id,E.sign_time having count(E.sign_time)>1

阅读(1059) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~