Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: can this sql work in crystal? Post Reply Post New Topic
Author Message
moondogi
Newbie
Newbie


Joined: 08 Oct 2008
Online Status: Offline
Posts: 5
Quote moondogi Replybullet Topic: can this sql work in crystal?
     Posted: 01 Dec 2008 at 8:42pm

I tried this in Access and seems to work ok, thought I'd try this in CrystalXI to emulate a Full Outer Join. 

It returns a syntax error (comma) in query expression on the first line.
     - is there a problem, can it be fixed?
 
 
SELECT  NZ(`sdscastings`.`Item_No`,`invlisting`.`Item_No`) as [FR/VN]
, `sdscastings`.`Item_Desc`
, `sdscastings`.`Description_Line_2`
, `sdscastings`.`Prime_Vendor`
, `sdscastings`.`Vendor_Product_No`
, `sdscastings`.`Production_Cat`
, `sdscastings`.`Production_Sub_Cat`
FROM   `Sheet1$` `sdscastings` LEFT JOIN `Sheet1$` `invlisting`
ON `sdscastings`.`Item_Desc`= `invlisting`.`Item_Desc`

UNION

SELECT  NZ(`sdscastings`.`Item_No`,`invlisting`.`Item_No`) as [FR/VN]
,
, `invlisting`.`Description_Line_2`
, `invlisting`.`Prime_Vendor`
, `invlisting`.`Vendor_Product_No`
, `invlisting`.`Production_Cat`
, `invlisting`.`Production_Sub_Cat`
FROM   `Sheet1$` `sdscastings` LEFT JOIN `Sheet1$` `invlisting`
ON `sdscastings`.`Item_Desc`= `invlisting`.`Item_Desc`

I have some other sql stuff in Access, can these be transported accross to Crystal? Or does SQL have different dialects?

 
btw, Full Outer Joins are not available in this report
JohnW
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 02 Dec 2008 at 6:33am
Hi,
 
To start, yes there are different versions of SQL.  Most are similar, but there are variations.
 
I'm not sure what NZ(`sdscastings`.`Item_No`,`invlisting`.`Item_No`) as [FR/VN] does.  It appears to be selecting 2 different fields at once, which is probably not the desired effect. If it is to use the first one if it is not null, and second if the first is null, then use COALESCE.  If its intent is something else, let us know and we will see what can be done.
 
Hope this helps
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 02 Dec 2008 at 11:11am

Are you trying to connect to an Excel spreadsheet?   If so, you may be more limited as to what types of statements you can use in your SQL - it may have to be plain vanilla ANSI 92 SQL, which is not the same as the SQL that you can use in Access.

-Dell
IP IP Logged
moondogi
Newbie
Newbie


Joined: 08 Oct 2008
Online Status: Offline
Posts: 5
Quote moondogi Replybullet Posted: 02 Dec 2008 at 4:41pm
Hi guys,
NZ is a calculated field to get a "merged" result of two tables
e.g. NOT like this:

FRef# OtherFields Vendor_No
101    blaha
102    blahb
103    blahc           103
104    blahd          104
          blahe          105
          blahf           106


What I really expect is a single collumn that represents Foundry Ref# &
Vendor_No e.g.

FR/VN OtherFields
101     blaha
102     blahb
103     blahc
104     blahd
105     blahe
106     blahf
I hope this explains my problem.
At the moment, I working in crystal, exporting the result as .xls, using Access to Join the tables, exporting to .xls, opening crystal to filter results, exporting to access, Join another table and report.
Very messy, I am hoping to get the job done on the one application.
JohnW
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