Hello

First of all, sorry for a long post and may not making any sense. My work is using IBM DB2 QMF and I'm just an end user with no access to the database and tables. I am allowed to create a query in QMF to customize a report for myself. Please give me some guidance and advice! Thank you so much!
Quote:
TABLES
---------
TABLE#1 FLORIDA.CURRENT_MONTH_ORDER :
COL 1: CUR_ORDER_NO
COL 2: CUR_ORDER_QTY
COL 3: CUR_ORDER_AMT
COL 4: ITEM_NO
COL 5: ITEM_DESCRIPTION
COL 6: CUSTOMER_ID
COL 7: ORDER_DATE
TABLE#2 FLORIDA.HISTORY_MONTH_ORDER :
COL 1: HISTORY_ORDER_NO
COL 2: HISTORY_ORDER_QTY
COL 3: HISTORY_ORDER_AMT
COL 4: ITEM_NO
COL 5: ITEM_DESCRIPTION
COL 6: CUSTOMER_ID
COL 7: ORDER_DATE
|
------------------------------------------------------------------------
I would like to write a query to generate a report with data pulled from both tables. Prompt for input will be the order date range. (from/to) How can I make column 1 through 3 teamed up and given them new names?
For example: I input a start Date of "1 January 2010" and End Date of "8 June
2010", for the "ORDER_DATE" Range. The report should show all of the orders from the dates range and displays 7 columns. Column 1 through Column 3 contains data from TABLE 1 and TABLE 2. And instead of the name CUR_ORDER_NO or HISTORY_ORDER_NO, the new column name is going to be just "ORDER_NO"
-------------------
TABLE#1 FLORIDA.CURRENT_MONTH_ORDER
This table keeps orders occured in the current month before being moved to the archived table at month-end
-------------------
TABLE#2 FLORIDA.HISTORY_MONTH_ORDER
This table archived orders from start to the last completed month (in this case, the most recent completed month is MAY 2010)
-------------------
I wrote something like this but it is not working...
SELECT DISTINCT
CUR_ORDER_NO, CUR_ORDER_QTY, CUR_ORDER_AMT,
ITEM_NO, ITEM_DESCRIPTION, CUSTOMER_ID, ORDER_DATE
FROM FLORIDA.CURRENT_MONTH_ORDER
WHERE ORDER_DATE => &FROM_DATE
AND ORDER_DATE =< &TO_DATE
UNION
SELECT
HISTORY_ORDER_NO, HISTORY_ORDER_QTY, HISTORY_ORDER_AMT,
ITEM_NO, ITEM_DESCRIPTION, CUSTOMER_ID, ORDER_DATE
FROM FLORIDA.HISTORY_MONTH_ORDER
WHERE ORDER_DATE => &FROM_DATE
AND ORDER_DATE =< &TO_DATE