I have 3 tables 'media','zone' and 'mediaplaycount' want to write query to fetch data to represent it in crosstab format.
media
medId medname
----- -------
1 media1
2 media2
3 media3
- -
- -
n xyz
zone
znId znName
----- ------
1 east
2 west
3 south
4 north
- -
- -
n xyz
mediaplaycount
medId znId playdate
------ ----- --------
1 2 1/12/2013
1 1 1/12/2013
3 3 1/12/2013
4 1 1/12/2013
what i want is mediaplacount for each media and zone combination. horizontal field will be all the zone and vertical will be media. result should have count of media against zone and look like
east west south north ----- ------ n
media1 1 1 0 0 0 0 0
media2 0 0 0 0 0 0 0
media3 0 0 1 0 0 0 0
media4 1 0 0 0 0 0 0
-----
n