Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: SQL expressions - can you use lists? Post Reply Post New Topic
Author Message
OmniPants
Newbie
Newbie
Avatar

Joined: 10 Mar 2010
Location: United Kingdom
Online Status: Offline
Posts: 3
Quote OmniPants Replybullet Topic: SQL expressions - can you use lists?
     Posted: 16 Jun 2010 at 2:25am
Allo,
 
I've hit a bit of a snag. I need to group a report on a formula field, but it takes a mortifyingly long time to run...
 
So, I thought I'd try to recreate the formula in SQL, to take advantage of server-side grouping.
 
The original formula looked rather like this:
 
if {table.myfield} in ["a","b","c"] then "Group One" else
if {table.myfield} in ["X","Y","Z"] then "Group Two" else "Error"
 
Can I reproduce this in an SQL expression? I can't seem to find a way of making a list...
 
Cheers!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 16 Jun 2010 at 4:11am
if you are using a stored proc, it would be simple.  I will be honest, I don't know how to do it in CR.  If the back end is SQL server, you probably want to add something like:
 CASE WHEN {table.field} in ('a','b','c') THEN 'Group 1'
 CASE WHEN {table.field} in ('x','y','z') THEN 'Group 2'
 ELSE 'Error' END AS GroupingField
 
HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum