/* Formatted on 1/31/2021 12:00:18 PM (QP5 v5.256.13226.35538) */
SELECT TYPE,
item_code,
item_name,
unit,
qc_refno,
qcdate,
mrrno,
mrrdate,
typecode,
typename,
qty,
VALUE,
ccode
FROM ( (SELECT 'Import' TYPE,
item_code,
item_name,
unit,
qc_refno,
qcdate,
mrrno,
mrrdate,
typecode,
typename,
importqty qty,
importvalue VALUE,
ccode
FROM STOCK_DETAIL_REPORT)
UNION ALL
(SELECT 'Local' TYPE,
item_code,
item_name,
unit,
qc_refno,
qcdate,
mrrno,
mrrdate,
typecode,
typename,
localqty qty,
localvalue VALUE,
ccode
FROM STOCK_DETAIL_REPORT)
UNION ALL
(SELECT 'Other Receive' TYPE,
item_code,
item_name,
unit,
qc_refno,
qcdate,
mrrno,
mrrdate,
typecode,
typename,
orecqty qty,
orecvalue VALUE,
ccode
FROM STOCK_DETAIL_REPORT)
UNION ALL
(SELECT 'Return' TYPE,
item_code,
item_name,
unit,
qc_refno,
qcdate,
mrrno,
mrrdate,
typecode,
typename,
retqty qty,
retvalue VALUE,
ccode
FROM STOCK_DETAIL_REPORT)
UNION ALL
(SELECT 'Issue' TYPE,
item_code,
item_name,
unit,
qc_refno,
qcdate,
mrrno,
mrrdate,
typecode,
typename,
issueqty qty,
issuevalue VALUE,
ccode
FROM STOCK_DETAIL_REPORT)
UNION ALL
(SELECT 'Other Issue' TYPE,
item_code,
item_name,
unit,
qc_refno,
qcdate,
mrrno,
mrrdate,
typecode,
typename,
oissueqty qty,
oissuevalue VALUE,
ccode
FROM STOCK_DETAIL_REPORT))
WHERE TYPE = :p_type
AND ccode = :p_ccode
AND (NVL (qty, 0)) > 0
AND typecode = :p_itemtype
\
Note :In the above query. I define some columns which I manipulate in the UNION ALL query.
Firstly you should understood it that how many columns I defined in the first select statement all the UNION ALL query the same column we will define .with out defining all the column we will get an error like " ORA-01789: query block has incorrect number of result columns ".
After all the where clause column are mentioned from the first select statement.
Thanks
No comments:
Post a Comment