select b.model, count(case when DATEPART(hh, u.unitcompleted) = '05' then 0 end) 'Hour_1',count(case when DATEPART(hh, u.unitcompleted) = '06' then 0 end) 'Hour_2',count(case when DATEPART(hh, u.unitcompleted) = '07' then 0 end) 'Hour_3',count(case when DATEPART(hh, u.unitcompleted) = '08' then 0 end) 'Hour_4',count(case when DATEPART(hh, u.unitcompleted) = '09' then 0 end) 'Hour_5',count(case when DATEPART(hh, u.unitcompleted) = '10' then 0 end) 'Hour_6',count(case when DATEPART(hh, u.unitcompleted) = '11' then 0 end) 'Hour_7',count(case when DATEPART(hh, u.unitcompleted) = '12' then 0 end) 'Hour_8',count(case when DATEPART(hh, u.unitcompleted) = '13' then 0 end) 'Hour_9',count(case when DATEPART(hh, u.unitcompleted) = '14' then 0 end) 'Hour_10',count(case when DATEPART(hh, u.unitcompleted) = '15' then 0 end) 'Hour_11',count(case when DATEPART(hh, u.unitcompleted) = '16' then 0 end) 'Hour_12',count(case when DATEPART(hh, u.unitcompleted) = '17' then 0 end) 'Hour_13',count(case when DATEPART(hh, u.unitcompleted) = '18' then 0 end) 'Hour_14',count(case when DATEPART(hh, u.unitcompleted) = '19' then 0 end) 'Hour_15',count(case when DATEPART(hh, u.unitcompleted) = '20' then 0 end) 'Hour_16',count(case when DATEPART(hh, u.unitcompleted) = '21' then 0 end) 'Hour_17',count(case when DATEPART(hh, u.unitcompleted) = '22' then 0 end) 'Hour_18',count(case when DATEPART(hh, u.unitcompleted) = '23' then 0 end) 'Hour_19',count(case when DATEPART(hh, u.unitcompleted) = '00' then 0 end) 'Hour_20'from completedUnit ujoin assignworkorder b on u.workorder = b.workorderwhere MONTH( u.dateentered ) = '6' and year(u.dateentered) = '2014'GROUP BY b.modelORDER BY b.model

select b.model, count(case when DATEPART(dw, u.dateentered) = '1' then 0 end) 'SUNDAY',count(case when DATEPART(dw, u.dateentered) = '2' then 0 end) 'MONDAY',count(case when datepart(dw, u.dateentered) = '3' then 0 end) 'TUESDAY',count(case when datepart(dw, u.dateentered) = '4' then 0 end) 'WEDNESDAY',count(case when datepart(dw, u.dateentered) = '5' then 0 end) 'THURSDAY',count(case when datepart(dw, u.dateentered) = '6' then 0 end) 'FRIDAY',count(case when DATEPART(dw, u.dateentered) = '7' then 0 end) 'SATURDAY'from completedUnit ujoin assignworkorder b on u.workorder = b.workorderwhere MONTH( u.dateentered ) = '6' and year(u.dateentered) = '2014'GROUP BY b.modelORDER BY b.model

from completedUnit ujoin assignworkorder b on u.workorder = b.workorderwhere u.dateentered >= '2014-06-01' and u.dateentered < '2014-07-01'GROUP BY b.modelORDER BY b.model

select b.model, count(case when substring(u.unitcompleted, 1,2) = '05' then 0 end) '5AM',count(case when substring(u.unitcompleted, 1,2) = '06' then 0 end) '6AM',count(case when substring(u.unitcompleted, 1,2) = '07' then 0 end) '7AM',count(case when substring(u.unitcompleted, 1,2) = '08' then 0 end) '8AM',count(case when substring(u.unitcompleted, 1,2) = '09' then 0 end) '9AM',count(case when substring(u.unitcompleted, 1,2) = '10' then 0 end) '10AM',count(case when substring(u.unitcompleted, 1,2) = '11' then 0 end) '11AM',count(case when substring(u.unitcompleted, 1,2) = '12' then 0 end) '12PM',count(case when substring(u.unitcompleted, 1,2) = '01' then 0 end) '1PM',count(case when substring(u.unitcompleted, 1,2) = '02' then 0 end) '2PM',count(case when substring(u.unitcompleted, 1,2) = '03' then 0 end) '3PM',count(case when substring(u.unitcompleted, 1,2) = '04' then 0 end) '4PM'from completedUnit ujoin assignworkorder b on u.workorder = b.workorderwhere MONTH( u.dateentered ) = '6' and year(u.dateentered) = '2014'GROUP BY b.modelORDER BY b.model

WHERE