moopan
07-28-2011, 04:56 AM
hi guys,
I have two table name tblhistory and tbltransaction. Both table have column name terminalno and clearingdate. I want get the transaction count based on clearing date and group by terminalno.
here is my coding
select TerminalNo, count (1) as COUNT from tbltransaction where
month(clearingdate) = Month('20110601')
and year(clearingdate) = year ('20110601')
group by terminalno
UNION ALL
select TerminalNo, count(1) as COUNT from tblhistory where
month(clearingdate) = month ('20110601')
and year(clearingdate) = year ('20110601')
group by terminalno
order by terminalno asc
example result from this codes:
Terminalno COUNT
V005------201
V005------298
V007------122
V007------110
BUT
how to get the result like this:
Terminalno COUNT
V005------499
V007------232
really appreciate any help.Thank you
I have two table name tblhistory and tbltransaction. Both table have column name terminalno and clearingdate. I want get the transaction count based on clearing date and group by terminalno.
here is my coding
select TerminalNo, count (1) as COUNT from tbltransaction where
month(clearingdate) = Month('20110601')
and year(clearingdate) = year ('20110601')
group by terminalno
UNION ALL
select TerminalNo, count(1) as COUNT from tblhistory where
month(clearingdate) = month ('20110601')
and year(clearingdate) = year ('20110601')
group by terminalno
order by terminalno asc
example result from this codes:
Terminalno COUNT
V005------201
V005------298
V007------122
V007------110
BUT
how to get the result like this:
Terminalno COUNT
V005------499
V007------232
really appreciate any help.Thank you