How to write sql query for below Result:
I have below table:
Amount Date Code
100 01-11-2014 USD
200 02-11-2014 USD
200 02-11-2014 INR
NULL 03-11-2014 NULL
NULL 04-11-2014 NULL
200 05-11-2014 INR
NULL 06-11-2014 NULL
NULL 07-11-2014 NULL
200 08-11-2014 USD
I need below result:
When the Amount is NULL for a given date, then need to show Amount as Zero for both the codes. Here for the date 03-11-2014, the Amount is NULL, so in the output, there are two rows for that date one for US and one for INR with Amount as Zero.
Amount Date Code
100 01-11-2014 USD
200 02-11-2014 USD
200 02-11-2014 INR
0 03-11-2014 USD
0 03-11-2014 INR
0 04-11-2014 USD
0 04-11-2014 INR
200 05-11-2014 INR
0 06-11-2014 INR
0 07-11-2014 INR
200 08-11-2014 USD