I am using Crystal XI and am trying to redo a report by writing a SQL statement and using the Command feature. I am fairly new to doing this. The biggest problem I am having is when I am trying to re-work reports that have several sub-reports within the main. The reason I have so many sub-reports included is because I am trying to pull data from the same database, but the various calculations I am doing require the data to be pulled from different date fields or different type of transactions within the database. As I was scanning this site, I found several suggestions to use "Union" or "Union All". I tried this but continue to get error messages. "Syntax error or access violation"
Any advice would be greatly appreciated.
Here is the code I am currently working with...
Any advice would be greatly appreciated.
Here is the code I am currently working with...
Code:
SELECT
WMTRANSACTIONDETAIL.QUANTITYACTUAL,
WMTRANSACTIONDP.PROFILECODE,
WMTRANSACTIONHEADER.STATUS,
WMTRANSACTIONHEADER.ACTUALRECEIVEDSHIPPEDDATETIME,
WMTRANSACTIONHEADER.STAGE,
WMTRANSACTIONHEADER.TRANSACTIONTYPE,
WMTRANSACTIONHEADER.CREATIONDATETIME,
WMTRANSACTIONHEADER.TRANSACTIONNUMBER,
WMTRANSACTIONDETAIL.NETWEIGHTQUANTITY,
WMTRANSACTIONHEADER.DELIVERYPICKUPDEPARTDATETIME,
IDMASTER_WAREHOUSE.IDENTITYID,
IMLOCATION.LOCATIONCODE
FROM (((WMTRANSACTIONHEADER WITH (NOLOCK)
LEFT OUTER JOIN IMLOCATION ON
WMTRANSACTIONHEADER.P_TRANSPORTATIONLOCATION=IMLOCATION.KEYSEQUENCE)
LEFT OUTER JOIN WMTRANSACTIONDETAIL WITH (NOLOCK) ON
WMTRANSACTIONHEADER.KEYSEQUENCE=WMTRANSACTIONDETAIL.P_TRANSACTIONHEADER)
INNER JOIN WMTRANSACTIONDP WITH (NOLOCK) ON
WMTRANSACTIONHEADER.P_PROFILE=WMTRANSACTIONDP.KEYSEQUENCE)
INNER JOIN IDMASTER IDMASTER_WAREHOUSE WITH (NOLOCK)
ON WMTRANSACTIONHEADER.P_TRANSPORTATIONWAREHOUSE=IDMASTER_WAREHOUSE.KEYSEQUENCE
WHERE
(WMTRANSACTIONHEADER.ACTUALRECEIVEDSHIPPEDDATETIME
between {?1 -Start_Date} and {?2 -End_Date}) and
{WMTRANSACTIONHEADER.STAGE} = 'C' and
{WMTRANSACTIONHEADER.STATUS} = 'L' and
{WMTRANSACTIONHEADER.TRANSACTIONTYPE} = 'S' and
{IDMASTER_WAREHOUSE.IDENTITYID} = 'BE'
UNION ALL
SELECT
WMTRANSACTIONHEADER.TRANSACTIONNUMBER,
WMTRANSACTIONHEADER.TRANSACTIONTYPE,
WMTRANSACTIONHEADER.CREATIONDATETIME,
IDMASTER_WAREHOUSE.IDENTITYID
FROM WMTRANSACTIONHEADER WITH (NOLOCK)
INNER JOIN IDMASTER IDMASTER_WAREHOUSE WITH (NOLOCK) ON
WMTRANSACTIONHEADER.P_TRANSPORTATIONWAREHOUSE=IDMASTER_WAREHOUSE.KEYSEQUENCE
WHERE
(WMTRANSACTIONHEADER.CREATIONDATETIME
between {?1 -Start_Date} and {?2 -End_Date})
AND WMTRANSACTIONHEADER.TRANSACTIONTYPE = 'R'
AND IDMASTER_WAREHOUSE.IDENTITYID = 'BE'