Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: SQL expression fields - link back to report table Post Reply Post New Topic
Author Message
JVDB
Newbie
Newbie


Joined: 23 Jan 2012
Online Status: Offline
Posts: 5
Quote JVDB Replybullet Topic: SQL expression fields - link back to report table
    Posted: 23 Jan 2012 at 5:06am

I started to explore sql expression fields some weeks ago but I have the following problem :

Our database has 3 main tables : workorder, operations and materials
 
This workorder table contains the header information but also the more detailed level information.
 
This header information can be filtered out by a specific column.
 
WORKORDER
 
ID DETAIL   PART
A     0          PARTNUMBER
A     1          EMPTY
A     2          EMPTY
 
In the crystal report I put all records from this workorder table but now I want to add this PART information only from ID = 'A' and DETAIL = '0' by using a sql expression fields.
 
I tried it like this
(
SELECT WORKORDER.PART
FROM WORKORDER
WHERE WORKORDER.ID = WORKORDER.ID AND WORKORDER.DETAIL = 0
)
 
If I change WORKORDER.ID into 'A' I have off course the correct answer.
 
If something like this is impossible I have also a view that I can use
 
(SELECT WORKORDERVIEW.PART
FROM WORKORDERVIEW
WHERE WORKORDERVIEW.ID = WORKORDER.ID
)
=> in this view I filtered out all the records with DETAIL = '0'
But this is also not working.
 
I keep on getting errors about WORKORDER.ID can't be bound or that this is
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 23 Jan 2012 at 5:54am

Your problem is in your where clause - "Where WORKORDER.ID = WORKORDER.ID will get you all of the data in the table.  Instead you need to alias the Workorder table your SQL expression.

This is probably going to slow down your report though.  A better way to do this would be to go to the Database Expert and add the Workorder table to your report a second time.  Crystal will alert you that the table is already in the report and ask you if you want to alias it - click on Yes (or maybe it's OK....)  The table will then appear in the list of selected tables as "WORKORDER_1".  Link from WORKORDER.ID to WORKORDER_1.ID.  Then, in the Select Expert set a filter on WORKORDER_1.DETAIL = 0.
 
-Dell
IP IP Logged
JVDB
Newbie
Newbie


Joined: 23 Jan 2012
Online Status: Offline
Posts: 5
Quote JVDB Replybullet Posted: 01 Feb 2012 at 11:38pm
I tried to put the alias in the sql but also this is not working
(
SELECT WORKORDER_1.PART
FROM WORKORDER WORKORDER_1
WHERE WORKORDER_1.ID = WORKORDER.ID AND WORKORDER_1.DETAIL = 0
)
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.