日期:2014-05-18 浏览次数:20594 次
declare @AppointTime datetime,@DeptID Nvarchar(50),@ShiftID Nvarchar(50),@WeekID Nvarchar(50) set @deptID='3' set @AppointTime='2012-2-2' set @ShiftID='8' set @WeekID='4' select count(*) AlreadyCount,app.Deptid,app.PeriodID,sd.MenCount ,shiftID ,sd.WeekID,app.AppointTime from ShiftDetail sd left join AppointList App on sd.ShiftID=@ShiftID and sd.WeekID=@WeekID and app.PeriodID=sd.PeriodID and app.AppointTime=@AppointTime group by app.AppointTime,app.DeptID,app.PeriodID ,sd.MenCount,shiftID,sd.WeekID order by app.periodID
select app.Deptid,app.PeriodID,sd.MenCount ,shiftID ,sd.WeekID,app.AppointTime from ShiftDetail sd left join AppointList App on sd.ShiftID=@ShiftID and sd.WeekID=@WeekID and app.PeriodID=sd.PeriodID and app.AppointTime=@AppointTime
------解决方案--------------------
select count(*) AlreadyCount,app.Deptid,app.PeriodID,sd.MenCount ,shiftID ,sd.WeekID,app.AppointTime
from ShiftDetail sd inner join AppointList App
on sd.ShiftID=@ShiftID and sd.WeekID=@WeekID and app.PeriodID=sd.PeriodID and app.AppointTime=@AppointTime
group by app.AppointTime,app.DeptID,app.PeriodID ,sd.MenCount,shiftID,sd.WeekID
order by app.periodID