Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case Statement in the SQL "Add Command" tool

Status
Not open for further replies.

2Plan

MIS
Mar 29, 2005
55
0
0
US
Does Crystal Reports "Add Command" utility allow you write Case statements.

Can anyone tell me how I can format the Query below into an equivalent query in Crystal Reports, using the "Add Command" utility? Or the Formula tool or the SQL Expression tool? Thanks in advance for any assistance.

Select
run, route,
Sum( CASE
WHEN fs in (1,2,4,5,6,7,8,9) and ev.ts between '2008-04-01 04:00:00.000' and '2008-04-02 03:59:00.000' THEN
ev.rdr_c
END) as "4/1",

Sum( CASE
WHEN fs in (1,2,4,5,6,7,8,9) and ev.ts between '2008-04-02 04:00:00.000' and '2008-04-03 03:59:00.000' THEN
ev.rdr_c
END) as "4/2",

Sum( CASE
WHEN fs in (1,2,4,5,6,7,8,9) and ev.ts between '2008-04-03 04:00:00.000' and '2008-04-04 03:59:00.000' THEN
ev.rdr_c
END) as "4/3"

from dba.ev key join dba.ml
where ev.ts between '2008-04-01 04:00:00.000' and '2008-05-01 03:59:00.000'

and run > 100
and route < 9000
group by run, route
order by run, route
 
Just retested the Query above and it works fine.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top