Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: SQL Problem Post Reply Post New Topic
Author Message
kiml
Newbie
Newbie


Joined: 06 Aug 2008
Location: Canada
Online Status: Offline
Posts: 6
Quote kiml Replybullet Topic: SQL Problem
     Posted: 01 Dec 2008 at 9:04am
I'm trying to filter out some data in a command and it is not working - I have the same SQL statement in my VB project and it works correctly - but is giving me problems with CR.
 
Here is the statement; I don't want descriptions that start with Z.
-----------------------------------------------
SELECT PCLASS FROM CPY10050
WHERE PDESCRIPTION NOT LIKE 'Z%'
UNION
SELECT '...ALL' FROM CPY10050
-------------
When I refresh and ask for a new prompt - all the divisions still come up
-----------------------------------------------------
I've done some searches since I first wrote this
and I've seen some code like this
WHERE right(t.eventstr,1)  NOT LIKE '%B'
 
I can find nothing in my book that explains this to me but I think it has to do with why my SQL Statement might not be working. 
----------------------------------------------------
I've have since found some more info on this:
 
I now have my where statement as follows
 
WHERE LEFT(PDescription,1) not like 'z'
 
but this still doesn't work
---------------------------------------------


Edited by kiml - 01 Dec 2008 at 10:47am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 02 Dec 2008 at 6:20am
How about WHERE LEFT(PDescription, 1) <> 'z'
 
Like tends to be used with wild cards (% matches any length string)to find strings that 'match' the picture, so '%B' is any string ending in 'B'.  Left and Right take the number of letters from the Left or Right side of the string, so LEFT('abcd', 2) = 'ab'
 
Also, as a note, since you only want the '...ALL', you don't need the FROM, ie UNION SELECT '...ALL'
 
Would have thought that the SQL you posted worked, seems correct...
 
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