I am using Oracle 11G, I have below table structure
STATE_DEF table is parent table
TAX_DEF_ID EFFECTIVE_DATE REP_TYPE
1 9-Jan-12 R
2 15-Jan-12 W
and child table ‘TAX_DETAIL’ as below
TAX_DETAIL_ID TAX_TYPE DISTRIBUTION_TYPE WH_RATE TAX_DEF_ID
1 I S 0.1 1
2 I P 0.12 1
3 D S 0.2 1
4 D P 0.22 1
5 I S 0.3 2
6 I P 0.31 2
7 D S 0.4 2
8 D P 0.41 2
I want to create a view which will given output shown below
TAX_DEF_ID EFFECTIVE_DATE I_S_WH_RATE I_P_WH_RATE D_S_WH_RATE D_P_WH_RATE
1 9-Jan-12 0.1 0.12 0.2 0.22
2 15-Jan-12 0.3 0.31 0.4 0.41
I had tried LISTAGG function but it would give me single column with concated columns. I am looking for the view definition which will give me rates in separate columns for a effective date.
I have been trying to get this output from couple of days. I would appretiate any help to achieve above result.
Try this: