Skip to Content
0
Former Member
Aug 25, 2009 at 06:24 PM

how to write this SQL

17 Views

i am sorry this is SQL question, but i could not find an appropriate section, so i post here

my question is

i need to pull something like

select convert(char(12), datetime,101), sum(...) as A, sum(...) as B

from table1

where case when condition1 then datepart(hh, datetime) between 8 and 18(which i want to pull the data between 8am to 18pm) when condition 2 then 'pull the data between 7am to 20pm end

how to write this where clause? i tried to write

where case when condition1 then datepart(hh, datetime) between 8 and 18 end, but it is wrong

do someone know?

thanks