Archive for May 1st, 2011

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 )

Read Full Post | Make a Comment ( None so far )

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

Follow

Get every new post delivered to your Inbox.