I have two different table on which i apply select query with some filters and aggregate functions like SUM,COUNT,SUBSTR.
I want to get these two different output in a s
If you are using union or union all to combine multiple query, then each query should have same number of columns with same data types.
Use below query:
SELECT a.message_type,a.queue_seqnum, b.queue_seqnum,SUBSTR (b.char_data,1,2)
files,0 as count FROM ad_in_messageheader a, ad_in_messagedetail b WHERE a.queue_seqnum =
b.queue_seqnum AND a.MESSAGE_TYPE in
('ERP_COSTS_SMRY','ERP_SALES_SMRY','ERP_SPEND_SMRY') AND
a.create_time > '17-DEC-13 07.00.00 AM'
union all
SELECT a.message_type,'' as queue_seqnum,'' as queue_seqnum, '' as files
count(a.message_type) count FROM ad_in_messageheader a
where a.MESSAGE_TYPE in ('ERP_COSTS','ERP_SALES','ERP_SPEND') AND
create_time > '17-DEC-13 07.00.00 AM' group by a.message_type
And you have to use order by
finally after combine both queries..