如何用SQL语句取得排班表的班别 ( 积分: 100 )

  • 主题发起人 主题发起人 fluganto
  • 开始时间 开始时间
F

fluganto

Unregistered / Unconfirmed
GUEST, unregistred user!
现在<br>排班表<br>工号&nbsp;年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;D1,D2...D31<br>001&nbsp;&nbsp;2007&nbsp;&nbsp;&nbsp;10&nbsp;A&nbsp;&nbsp;B...&nbsp;C<br>D1,D2..D31中本月各天的排班<br><br>考勤表<br>工号&nbsp;日期&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;班别<br>001&nbsp;&nbsp;2007-10-5<br>如何用SQL语句取消对应工号对应日期的班别(D1,D2..D31中的值)<br><br>谢谢!!
 
case&nbsp;day(日期)&nbsp;when&nbsp;1&nbsp;then&nbsp;D1&nbsp;when&nbsp;2&nbsp;then&nbsp;D2&nbsp;when&nbsp;3&nbsp;then&nbsp;D3...&nbsp;end
 
或者可以这样:<br>declare&nbsp;@sql&nbsp;nvarchar(1000)<br>set&nbsp;@sql=N'select&nbsp;工号,&nbsp;''2007-10-5''&nbsp;as&nbsp;日期,&nbsp;D'&nbsp;+&nbsp;day('2007-10-5')&nbsp;+&nbsp;'&nbsp;as&nbsp;班别&nbsp;from&nbsp;排班表&nbsp;where&nbsp;年=year(''2007-10-5'')&nbsp;and&nbsp;月=month(''2007-10-5'')'<br>exec&nbsp;sp_executesql&nbsp;@sql
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部