I have the following query I am trying to run:
select datefilled,
case len(timefilled)
when 7 then SUBSTRING(CAST(timefilled as varchar),1,1)
else SUBSTRING(CAST(timefilled as varchar),1,2)
end A
from ScriptHistory
where datefilled > getdate()-7
group by timefilled,datefilled
I...