버전은 PostgreSQL 10.15 입니다
테이블 A
컬럼 PD_YM, PROD_NAME, PD_PRCE 이 3가지 컬럼을 이용해
PD_YM | PROD_NM | PD_PRCE |
2020-02 | 제품A | 148668 |
2020-02 | 제품B | 580009 |
2020-02 | 제품C | 2072581 |
2020-02 | 제품D | 3825335 |
2020-03 | 제품A | 148668 |
2020-03 | 제품B | 580009 |
2020-03 | 제품C | 2072581 |
2020-03 | 제품D | 3825335 |
아래와 같은 json 형식을 만들고 싶습니다.
{
"year": "2020-02",
"제품A": 148668,
"제품B": 2072581 ,
"제품C": 0
},
{
"year": "2020-03",
"제품A": 148668,
"제품B": 2072581 ,
"제품C": 0
},
와 감사합니다 마농님
조금씩 수정하고 조립하여 드디어 완성 했습니다.
{"year:2020-02","TAGRISSO Tablets 40mg 4 X 7 Blister":2072581,"TAGRISSO Tablets 80mg 4 X 7 Blister":3825335,"Imfinzi Liquid 500mg 1 x 10ml Vial":580009,"Imfinzi Liquid 120mg 1 X 2.4ml Vial ":148668},
{"year:2020-03","TAGRISSO Tablets 80mg 4 X 7 Blister":3825335,"Imfinzi Liquid 120mg 1 X 2.4ml Vial ":148668,"TAGRISSO Tablets 40mg 4 X 7 Blister":2072581,"Imfinzi Liquid 500mg 1 x 10ml Vial":580009},
{"year:2020-04","Imfinzi Liquid 500mg 1 x 10ml Vial":1895865,"Lynparza Tablets 100mg 7 x 8 blister":1132679,"TAGRISSO Tablets 80mg 4 X 7 Blister":3825335,"Imfinzi Liquid 120mg 1 X 2.4ml Vial ":472605,"TAGRISSO Tablets 40mg 4 X 7 Blister":2072581,"Lynparza Tablets 150mg 7 x 8 blister":1415839},
{"year:2020-05","TAGRISSO Tablets 40mg 4 X 7 Blister":2072581,"Imfinzi Liquid 500mg 1 x 10ml Vial":1824946,"Lynparza Tablets 100mg 7 x 8 blister":1132679,"Lynparza Tablets 150mg 7 x 8 blister":1415839,"Imfinzi Liquid 120mg 1 X 2.4ml Vial ":465979,"TAGRISSO Tablets 80mg 4 X 7 Blister":3825335},