Topic: SQL Question Posted: 06 Feb 2014 at 10:12am
I am new to SQL. I have made one of my reports using only the SQL command in database expert, however I had to use the standard crystal methods for the below two formulas
Formula: if {Table.XYZ} = "Apples" then 1 else 0
then in select expert I have this as a group selection formula maximum({@Formula}, {Table2.ABC}) = 1
Is there a way to write this into the SQL command?
Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Posted: 06 Feb 2014 at 11:09am
select {Table2.ABC},
max(case when {Table.XYZ} = 'Apples' then 1 else 0 end) as [field name]
from sometable
group by {Table2.ABC}
having max(case when {Table.XYZ} = 'Apples' then 1 else 0 end) = 1
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