Subject | RE: [IBO] SQL Help |
---|---|
Author | Jason Wharton |
Post date | 2008-01-30T22:52:24Z |
What you should do is add a clause to your query like this:
SELECT ( SELECT MAX( TBL_B.ORDER_DATE )
FROM TBL_B
WHERE TBL_B.CUST_ID = TBL_A.CUST_ID ) AS LAST_ORDER_DATE
, TBL_A
FROM TBL_A
ORDER BY 1
This way if there isn't an order it will return NULL for the
LAST_ORDER_DATE.
HTH,
Jason Wharton
SELECT ( SELECT MAX( TBL_B.ORDER_DATE )
FROM TBL_B
WHERE TBL_B.CUST_ID = TBL_A.CUST_ID ) AS LAST_ORDER_DATE
, TBL_A
FROM TBL_A
ORDER BY 1
This way if there isn't an order it will return NULL for the
LAST_ORDER_DATE.
HTH,
Jason Wharton