警报基于按组别汇总的IF报表?

时间:2016-04-14 18:34:04

标签: sql-server if-statement group-by alert

我想只在员工每天工作时间低于6.00时创建此提醒,目前我的代码统计了所有员工的所有时间,如何为每位员工创建提醒

declare @totalhrs int
SELECT @totalhrs = SUM(duration) 
FROM pl00.DBO.schedule
where (schedule.DATE  = CONVERT(char(10), getdate()+2, 121)
and schedule.TYPE <> 'z')
group by EMP_ID, schedule.DATE

    if(@totalhrs < 6) 
    begin

    EXEC msdb.dbo.sp_send_dbmail
    @profile_name = 'mail.pacificlawnsprinklers.com',
    @recipients = 'mmahoney@pacificlawnsprinklers.com',
    @query = '

    SET NOCOUNT ON;

    SELECT EMP_ID, DateName(weekday, Cast(schedule.DATE AS date)),schedule.[DATE], SUM(duration) as TotalHrs 
    FROM pl00.DBO.schedule
    where (schedule.DATE  = CONVERT(char(10), getdate()+2, 121)
    and schedule.TYPE <> "Z")
    group by EMP_ID, schedule.DATE
    ',
    @subject = 'Lights Lists to Review',
    @attach_query_result_as_file = 0 ;

    end

1 个答案:

答案 0 :(得分:0)

删除mysql标记。

尝试此查询:

$.when($(".expand").before("<span class='clickActivate'>Click to see more</span>")).then(function(){
    $(".clickActivate").click(function(){
        $(this).next().toggle();
    })
});