Using a MySQL database I want to store daily measurements of different "channels":
date | channel | value
-----+---------+------
1.1. | 'A' | 1
1.1. | 'B' | 2
1.1. | 'C' | 3
2.1. | 'A' | 4
2.1. | 'C' | 5
3.1. | 'A' | 6
3.1. | 'B' | 7
3.1. | 'C' | 8
4.1. | 'A' | 9
4.1. | 'B' | 10
4.1. | 'C' | 11
Each day the then available channels will be inserted (in the table above the channel 'B' wasn't available on the 2.1.). There will not be more than one measurement per channel per day, i.e. (date,channel)
is always unique.
My question:
What is the SQL command to retrieve that data in one table, i.e. a result looking like:
date | A | B | C
-----+----+----+---
1.1. | 1 | 2 | 3
2.1. | 4 | - | 5
3.1. | 6 | 7 | 8
4.1. | 9 | 10 | 11
Optional task: the channel are just a channel ID and a different table maps the ID to the channel name.
(Actually I thought that this is so trivial that there are examples about it everywhere. But either my search engine is broken or I'm trying to do something strange here...)
Note: SQL Cross Tab Function doesn't solve this question as I need the result in separate columns and not aggregated into one.