m@rc-lenzin

Wenn etwas schief geht, dann freu dich. Das sind die Geschichten die dir in Erinnerung bleiben werden

Ky2Help – Task count by Day and Hour

select	substring(a,1,4)+'-'+
		substring(a,5,2)+'-'+
		substring(a,7,2) as DATUM,
		isnull(cast(sum(case when SUBSTRING(a,9,2) =  0 then 1 else null end) as varchar),'') as "h00",
		isnull(cast(sum(case when SUBSTRING(a,9,2) =  1 then 1 else null end) as varchar),'') as "h01",
		isnull(cast(sum(case when SUBSTRING(a,9,2) =  2 then 1 else null end) as varchar),'') as "h02",
		isnull(cast(sum(case when SUBSTRING(a,9,2) =  3 then 1 else null end) as varchar),'') as "h03",
		isnull(cast(sum(case when SUBSTRING(a,9,2) =  4 then 1 else null end) as varchar),'') as "h04",
		isnull(cast(sum(case when SUBSTRING(a,9,2) =  5 then 1 else null end) as varchar),'') as "h05",
		isnull(cast(sum(case when SUBSTRING(a,9,2) =  6 then 1 else null end) as varchar),'') as "h06",
		isnull(cast(sum(case when SUBSTRING(a,9,2) =  7 then 1 else null end) as varchar),'') as "h07",
		isnull(cast(sum(case when SUBSTRING(a,9,2) =  8 then 1 else null end) as varchar),'') as "h08",
		isnull(cast(sum(case when SUBSTRING(a,9,2) =  9 then 1 else null end) as varchar),'') as "h09",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 10 then 1 else null end) as varchar),'') as "h10",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 11 then 1 else null end) as varchar),'') as "h11",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 12 then 1 else null end) as varchar),'') as "h12",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 13 then 1 else null end) as varchar),'') as "h13",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 14 then 1 else null end) as varchar),'') as "h14",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 15 then 1 else null end) as varchar),'') as "h15",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 16 then 1 else null end) as varchar),'') as "h16",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 17 then 1 else null end) as varchar),'') as "h17",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 18 then 1 else null end) as varchar),'') as "h18",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 19 then 1 else null end) as varchar),'') as "h19",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 20 then 1 else null end) as varchar),'') as "h20",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 21 then 1 else null end) as varchar),'') as "h21",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 22 then 1 else null end) as varchar),'') as "h22",
		isnull(cast(sum(case when SUBSTRING(a,9,2) = 23 then 1 else null end) as varchar),'') as "h23",
		COUNT(*) as cnt
  from	(select masfld022 as a from dbo.TMASTER70) a
  group by	substring(a,1,4)+'-'+
			substring(a,5,2)+'-'+
			substring(a,7,2)
  order by 1 desc

 

Weiter Beitrag

Zurück Beitrag

© 2025 m@rc-lenzin

Thema von Anders Norén