Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help with OR select statement Post Reply Post New Topic
Author Message
dibblejon
Newbie
Newbie


Joined: 05 Jan 2011
Location: United Kingdom
Online Status: Offline
Posts: 32
Quote dibblejon Replybullet Topic: Help with OR select statement
     Posted: 01 Aug 2012 at 12:51am
Hi
 
I have this criteria in my select statement but data is not returning as it should : basically where I state ainvhead.salesman = "2" it's not pulling this data - any help would as usual be great!
 
{ainvdet.layout_section} = "D" and
{ainvdet.invoice_date} in {?Date from} to {?Date to} and
{ainvhead.salesman} like ["*67*", "*75*", "*76*", "*78*", "*79*", "*83*", "*85*"] and
{sysuser.job_description} = "Customer Services Advisor"
and not ({ainvdet.part} startswith ["SMP", "LEA", "ABC"])
and if {?Selection} = "Group" then {ainvdet.product_group} = {?Group}
else if {?Selection} = "Family" then {stock.price_family} = {?Family}
or
{ainvdet.layout_section} = "D" and
{ainvdet.invoice_date} in {?Date from} to {?Date to} and
{sysuser.job_description} = "Customer Services Advisor" and
{ainvhead.salesman} = "2"
and not ({ainvdet.part} startswith ["SMP", "LEA", "ABC"])
and if {?Selection} = "Group" then {ainvdet.product_group} = {?Group}
else if {?Selection} = "Family" then {stock.price_family} = {?Family}
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Aug 2012 at 3:36am
there are a few problems with the satemetn but the only difference between the first and second part is the addition of the salesman=2 portion.
part 1 will already include all of these records so part 2 is moot.
what were you trying to diiferentiate?
IP IP Logged
yggdrasil
Senior Member
Senior Member
Avatar

Joined: 19 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 150
Quote yggdrasil Replybullet Posted: 01 Aug 2012 at 4:23am
Try this:-
 
{ainvdet.layout_section} = "D" and
{ainvdet.invoice_date} in {?Date from} to {?Date to} and

({ainvhead.salesman} like ["*67*", "*75*", "*76*", "*78*", "*79*", "*83*", "*85*"]  OR {ainvhead.salesman} = "2")
 
and {sysuser.job_description} = "Customer Services Advisor"
and not ({ainvdet.part} startswith ["SMP", "LEA", "ABC"])
and if {?Selection} = "Group" then {ainvdet.product_group} = {?Group}
else if {?Selection} = "Family" then {stock.price_family} = {?Family}
 
The problem with your version is lack of brackets, I think. You should have put brackets round each of the big clauses either side of the OR. But you don't need to repeat all the conditions hence what I have put above.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Aug 2012 at 4:37am
ahhh...missed that part in the first portion.
i would only recommend avoiding the if-then and changing the last part to
 
and
(
({?Selection} = "Group" and {ainvdet.product_group} = {?Group})
or
({?Selection} = "Family" and {stock.price_family} = {?Family})
)
IP IP Logged
dibblejon
Newbie
Newbie


Joined: 05 Jan 2011
Location: United Kingdom
Online Status: Offline
Posts: 32
Quote dibblejon Replybullet Posted: 02 Aug 2012 at 2:33am
Thanks - it's always brackets that gets me!
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