Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Variables in Select Statement Post Reply Post New Topic
Author Message
novc
Newbie
Newbie
Avatar

Joined: 20 Feb 2009
Online Status: Offline
Posts: 1
Quote novc Replybullet Topic: Variables in Select Statement
     Posted: 20 Feb 2009 at 10:13am
I have written a crystal report with the following query:
 
select distinct(substr(rg_grade.letter_04,1,1)) Grade, count(substr(rg_grade.letter_04,1,1)) Count, rg_course.department_id,rg_course.grade_level
from rg_grade,rg_course,rg_student
where rg_grade.course_id=rg_course.id
and rg_grade.student_id=rg_student.id
and student_group='Active'
and rg_grade.letter_04 is not null
and rg_student.current_grade in ('5','6','7','8')
and rg_course.id not in ('ENG0840','ENG0850','SOC0850')
group by substr(rg_grade.letter_04,1,1),rg_course.department_id,
rg_course.grade_level
order by rg_course.department_id
 
This is giving me the information I need.  What I want to do is replace  "letter_04" with a variable so that I can provide that information at the time I run the report, and pull a different column from my table (could be letter_01,letter_02 ... etc.)  Does anyone know how to get this done in crystal?  I can do parameters in the where clause, just not sure how to get it done in my select clause.  Any help is appreciated!
 
IP IP Logged
themessenger
Groupie
Groupie
Avatar

Joined: 15 Aug 2008
Location: United Kingdom
Online Status: Offline
Posts: 48
Quote themessenger Replybullet Posted: 23 Mar 2009 at 5:33am
Hi
 
Why not pull in the full string and handle the substring in a formula in the report?  You would be able to specify the param then.
 
Regard,
 
The Mesenger
Managing Director
www.allmymenus.com
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 23 Mar 2009 at 1:45pm
depending on the version of SQL, you might try a CASE WHEN statement, or you could pull in all of the columns that you might want and then you could write a formula to determine which column to display in the same spot, of course.
 
Hope this helps.
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