A way to get data from two tables using union

Posted on 01/05/2011. Filed under: Uncategorized |

 

(SELECT  tableA.CID,tableA.Student_Name , Currency.name as CurrencyName,SUM(Payments.amount)AS total, SUM(Payments.amount)AS Numtickets

FROM Payments innerjoin Currency on Payments.Currency=Currency.code innerjoin EmissaryUniversity on tableA.CID=Payments.CIDGROUPBY tableA.CID,tableA.Student_Name , Currency.name )union

(Select tableA.CID,tableA.Student_Name ,‘CurrencyName’=‘ ‘,Sum(tickets.ticketsNum)as total, Sum(tickets.ticketsNum)as Numtickets from tickets

innerjoin tableA on tableA.CID=Tickets.CID 

groupby tableA.CID,tableA .Student_Name )

Advertisement

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Liked it here?
Why not try sites on the blogroll...

Follow

Get every new post delivered to your Inbox.