MySQL Forums :: Newbie :: Need help with a Query....cross tab format


Advanced Search

Need help with a Query....cross tab format
Posted by: sridhar ventapalli ()
Date: July 28, 2010 07:08AM

Hello Friends..here is my problem

i have a table farebox(busnum,route,direction,revdt,fare) like this

bus|rt|dir|revenuedate|fare
=======================
101|1 |N |07/01/2010| 4
102|1 |N |07/01/2010| 3
103|1 |S |07/02/2010| 5
103|2 |E |07/03/2010| 3
.
.
.
2000|1|W|07/31/2010|4

(sorry, try to match the values with labels)


it goes on like this

now I need to get data in this format

Rout|dir|July1|July2|July3|...........| July31|
..1..|.N.|..7..|..0..|..0..|...........| 0
..1..|.S.|..0..|..5..|..0..|...........| 0

the columns with date label is nothing but sum of fare on that date for perticular route and direction.(dots are just for format sake)

Any sort of help is Appriciated.

Cheers
Sridhar

Options: ReplyQuote


Subject Written By Posted
Need help with a Query....cross tab format sridhar ventapalli 07/28/2010 07:08AM
Re: Need help with a Query....cross tab format Chad Bourque 07/28/2010 07:43AM
Re: Need help with a Query....cross tab format sridhar ventapalli 07/28/2010 07:54AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.