//string sql_plan = @" select PartNo, PlanCount from tb_InjectionPlan where StationID = '" + dt.Rows[0]["StationID"].ToString() + "' AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC ";
sql3=@" SELECT InjectionPlanID, PlanCount,CompleteCount,BadCount,Qty FROM tb_InjectionPlan WHERE StationID = '"+stationID+@"' AND ( StockNo = '"+stockNo+
"' OR PartNo = '"+partNo+"' ) AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC ";
sql3=@" SELECT InjectionPlanID, PlanCount,CompleteCount,BadCount,Qty FROM tb_InjectionPlan WHERE StationID = '"+stationID+@"' AND (StockNo = '"+stockNo+
"'or PartNo = '"+partNo+"') AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC ";
//string sql_plan = @" select PartNo, PlanCount from tb_InjectionPlan where StationID = '" + dt.Rows[0]["StationID"].ToString() + "' AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC ";
// SELECT barcode,CreateTime FROM dbo.tb_StockIn WHERE createTime BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 07:30:01') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 19:30:00') AND pass=1
// ORDER BY createTime DESC
// OPEN cursor_name --打开游标
// FETCH NEXT FROM cursor_name INTO @barcode ,@createTime --抓取下一行游标数据
// WHILE @@FETCH_STATUS = 0
// BEGIN
// SELECT TOP 1 @productInfo=productInfo FROM dbo.tb_InspectResult WHERE barcode=@barcode ORDER BY createTime DESC
//
// insert into #a1(BarCode,ProductInfo,CreateTime) values(@barcode,@productInfo,@createTime)
// --PRINT '用户ID:'+@productInfo
// FETCH NEXT FROM cursor_name INTO @barcode,@createTime
// END
// CLOSE cursor_name --关闭游标
// DEALLOCATE cursor_name --释放游标
//
// SELECT COUNT(0) AS c1 ,
// (SELECT COUNT(0) FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 07:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 08:29:59.999')) AND productInfo LIKE '%槛%') c2,08 AS h
// FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 07:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 08:29:59.999')) AND productInfo LIKE '%保%'
// UNION ALL SELECT COUNT(0) AS c1 ,
// (SELECT COUNT(0) FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 08:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 09:29:59.999')) AND productInfo LIKE '%槛%') c2,09 AS h
// FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 08:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 09:29:59.999')) AND productInfo LIKE '%保%'
// UNION ALL SELECT COUNT(0) AS c1 ,
// (SELECT COUNT(0) FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 09:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 10:29:59.999')) AND productInfo LIKE '%槛%') c2,10 AS h
// FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 09:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 10:29:59.999')) AND productInfo LIKE '%保%'
// UNION ALL SELECT COUNT(0) AS c1 ,
// (SELECT COUNT(0) FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 10:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 11:29:59.999')) AND productInfo LIKE '%槛%' ) c2,11 AS h
// FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 10:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 11:29:59.999')) AND productInfo LIKE '%保%'
// UNION ALL SELECT COUNT(0) AS c1 ,
// (SELECT COUNT(0) FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 11:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 12:29:59.999')) AND productInfo LIKE '%槛%' ) c2,12 AS h
// FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 11:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 12:29:59.999')) AND productInfo LIKE '%保%'
// UNION ALL SELECT COUNT(0) AS c1 ,
// (SELECT COUNT(0) FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 12:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 13:29:59.999')) AND productInfo LIKE '%槛%' ) c2,13 AS h
// FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 12:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 13:29:59.999')) AND productInfo LIKE '%保%'
// UNION ALL SELECT COUNT(0) AS c1 ,
// (SELECT COUNT(0) FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 13:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 14:29:59.999')) AND productInfo LIKE '%槛%') c2,14 AS h
// FROM #a1 WHERE ([createTime]BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 13:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 14:29:59.999')) AND productInfo LIKE '%保%'
// UNION ALL SELECT COUNT(0) AS c1 ,
// (SELECT COUNT(0) FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 14:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 15:29:59.999')) AND productInfo LIKE '%槛%') c2,15 AS h
// FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 14:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 15:29:59.999')) AND productInfo LIKE '%保%'
// UNION ALL SELECT COUNT(0) AS c1 ,
// (SELECT COUNT(0) FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 15:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 16:29:59.999')) AND productInfo LIKE '%槛%') c2,16 AS h
// FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 15:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 16:29:59.999')) AND productInfo LIKE '%保%'
// UNION ALL SELECT COUNT(0) AS c1 ,
// (SELECT COUNT(0) FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 16:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 17:29:59.999')) AND productInfo LIKE '%槛%') c2,17 AS h
// FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 16:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 17:29:59.999')) AND productInfo LIKE '%保%'
// UNION ALL SELECT COUNT(0) AS c1 ,
// (SELECT COUNT(0) FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 17:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 18:29:59.999')) AND productInfo LIKE '%槛%' ) c2,18 AS h
// FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 17:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 18:29:59.999')) AND productInfo LIKE '%保%'
// UNION ALL SELECT COUNT(0) AS c1 ,
// (SELECT COUNT(0) FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 18:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 19:29:59.999')) AND productInfo LIKE '%槛%') c2,19 AS h
// FROM #a1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 18:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 19:29:59.999')) AND productInfo LIKE '%保%'
// SELECT barcode,CreateTime FROM dbo.tb_StockIn WHERE createTime BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 19:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 23:59:59.999') AND pass=1
// ORDER BY createTime DESC
// OPEN cursor_name --打开游标
// FETCH NEXT FROM cursor_name INTO @barcode ,@createTime --抓取下一行游标数据
// WHILE @@FETCH_STATUS = 0
// BEGIN
// SELECT TOP 1 @productInfo=productInfo FROM dbo.tb_InspectResult WHERE barcode=@barcode ORDER BY createTime DESC
//
// insert into #b1(BarCode,ProductInfo,CreateTime) values(@barcode,@productInfo,@createTime)
// --PRINT '用户ID:'+@productInfo
// FETCH NEXT FROM cursor_name INTO @barcode,@createTime
// END
// CLOSE cursor_name --关闭游标
// DEALLOCATE cursor_name --释放游标
//
// SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #b1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 19:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:29:59.999')) AND productInfo LIKE '%槛%') c2,20 AS h
// FROM #b1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 19:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:29:59.999')) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #b1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 21:29:59.999')) AND productInfo LIKE '%槛%') c2,21 AS h
// FROM #b1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 21:29:59.999')) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #b1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 21:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 22:29:59.999')) AND productInfo LIKE '%槛%') c2,22 AS h
// FROM #b1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 21:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 22:29:59.999')) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #b1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 22:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 23:29:59.999')) AND productInfo LIKE '%槛%' ) c2,23 AS h
// FROM #b1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 22:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 23:29:59.999')) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #b1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 23:30:00.000') AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 00:29:59.999'))) AND productInfo LIKE '%槛%') c2,00 AS h
// FROM #b1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 23:30:00.000') AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 00:29:59.999'))) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 00:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 01:29:59.999'))) AND productInfo LIKE '%槛%' ) c2,01 AS h
// FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 00:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 01:29:59.999'))) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 01:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 02:29:59.999'))) AND productInfo LIKE '%槛%' ) c2,02 AS h
// FROM #b1 WHERE ([createTime]BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 01:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 02:29:59.999'))) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 02:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 03:29:59.999'))) AND productInfo LIKE '%槛%' ) c2,03 AS h
// FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 02:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 03:29:59.999'))) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 03:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 04:29:59.999'))) AND productInfo LIKE '%槛%' ) c2,04 AS h
// FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 03:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 04:29:59.999'))) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 04:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 05:29:59.999'))) AND productInfo LIKE '%槛%') c2,05 AS h
// FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 04:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 05:29:59.999'))) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 05:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 06:29:59.999'))) AND productInfo LIKE '%槛%' ) c2,06 AS h
// FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 05:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 06:29:59.999'))) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 06:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 07:29:59.999'))) AND productInfo LIKE '%槛%' ) c2,07 AS h
// FROM #b1 WHERE ([createTime] BETWEEN DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 06:30:00.000')) AND DATEADD(DAY,1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 07:29:59.999'))) AND productInfo LIKE '%保%' ";
// SELECT barcode,CreateTime FROM dbo.tb_StockIn WHERE createTime BETWEEN DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 19:30:00.000')) AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 07:30:00.000') AND pass=1
// ORDER BY createTime DESC
// OPEN cursor_name --打开游标
// FETCH NEXT FROM cursor_name INTO @barcode ,@createTime --抓取下一行游标数据
// WHILE @@FETCH_STATUS = 0
// BEGIN
// SELECT TOP 1 @productInfo=productInfo FROM dbo.tb_InspectResult WHERE barcode=@barcode ORDER BY createTime DESC
//
// insert into #c1(BarCode,ProductInfo,CreateTime) values(@barcode,@productInfo,@createTime)
// --PRINT '用户ID:'+@productInfo
// FETCH NEXT FROM cursor_name INTO @barcode,@createTime
// END
// CLOSE cursor_name --关闭游标
// DEALLOCATE cursor_name --释放游标
//
// SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #c1 WHERE ([createTime] BETWEEN DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 19:30:00.000')) AND DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:29:59.999'))) AND productInfo LIKE '%槛%') c2,20 AS h
// FROM #c1 WHERE ([createTime] BETWEEN DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 19:30:00.000')) AND DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:29:59.999'))) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #c1 WHERE ([createTime] BETWEEN DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:30:00.000')) AND DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 21:29:59.999'))) AND productInfo LIKE '%槛%') c2,21 AS h
// FROM #c1 WHERE ([createTime] BETWEEN DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 20:30:00.000')) AND DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 21:29:59.999'))) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #c1 WHERE ([createTime] BETWEEN DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 21:30:00.000')) AND DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 22:29:59.999'))) AND productInfo LIKE '%槛%') c2,22 AS h
// FROM #c1 WHERE ([createTime] BETWEEN DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 21:30:00.000')) AND DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 22:29:59.999'))) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #c1 WHERE ([createTime] BETWEEN DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 22:30:00.000')) AND DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 23:29:59.999'))) AND productInfo LIKE '%槛%') c2,23 AS h
// FROM #c1 WHERE ([createTime] BETWEEN DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 22:30:00.000')) AND DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 23:29:59.999'))) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #c1 WHERE ([createTime] BETWEEN DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 23:30:00.000')) AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 00:29:59.999')) AND productInfo LIKE '%槛%') c2,00 AS h
// FROM #c1 WHERE ([createTime] BETWEEN DATEADD(DAY,-1,CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 23:30:00.000')) AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 00:29:59.999')) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 00:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 01:29:59.999')) AND productInfo LIKE '%槛%') c2,01 AS h
// FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 00:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 01:29:59.999')) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 01:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 02:29:59.999')) AND productInfo LIKE '%槛%') c2,02 AS h
// FROM #c1 WHERE ([createTime]BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 01:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 02:29:59.999')) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 02:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 03:29:59.999')) AND productInfo LIKE '%槛%' ) c2,03 AS h
// FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 02:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 03:29:59.999')) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 03:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 04:29:59.999')) AND productInfo LIKE '%槛%') c2,04 AS h
// FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 03:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 04:29:59.999')) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 04:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 05:29:59.999')) AND productInfo LIKE '%槛%') c2,05 AS h
// FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 04:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 05:29:59.999')) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 05:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 06:29:59.999')) AND productInfo LIKE '%槛%') c2,06 AS h
// FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 05:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 06:29:59.999')) AND productInfo LIKE '%保%'
// UNION all SELECT COUNT(*) AS c1 ,
// (SELECT COUNT(*) FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 06:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 07:29:59.999')) AND productInfo LIKE '%槛%') c2,07 AS h
// FROM #c1 WHERE ([createTime] BETWEEN CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 06:30:00.000') AND CONVERT(DATETIME,SUBSTRING(CONVERT(NVARCHAR(50),GETDATE(),120),1,10)+ ' 07:29:59.999')) AND productInfo LIKE '%保%' ";
// select PaintCode,BucketCode,CreateTime, CASE [State] WHEN 0 THEN '空闲' WHEN 1 THEN '绑定' WHEN 2 THEN '清洗' END AS BucketState
// from tb_AddColorRecord order by BucketCode
// ";
stringsql=@"select a.PaintCode,a.BucketCode,a.CreateTime, CASE a.[State] WHEN 0 THEN '空闲' WHEN 1 THEN '绑定' WHEN 2 THEN '清洗' END AS BucketState,ISNULL(b.PaintName,'') AS PaintName