HI All
I get below output from my HANA model. For the billing item 001710 I get 2 lines. I only want to display the line where the NEW_DEL_DATE is MAX
How can I achieve this? I have written a SQL script model
Billing Document | Billing item | Billing Date | TO_DATE_EUDAT | TO_DATE_WADAT | NEW_DEL_DATE | Cost - Comp Code Curr | Net Value - Comp Code Curr | GET_DAYS | TRAN_TIME | DEL_DATE_CALC |
9043128697 | 000010 | 20140801 | 8/12/2014 | 8/1/2014 | 8/12/2014 | 482.160 | 642.880 | 2 | 11 | 11 |
000060 | 20140801 | 8/12/2014 | 8/1/2014 | 8/12/2014 | 89.060 | 181.130 | 2 | 11 | 11 | |
000080 | 20140801 | 8/12/2014 | 8/1/2014 | 8/12/2014 | 136.000 | 181.330 | 2 | 11 | 11 | |
000090 | 20140801 | 8/12/2014 | 8/1/2014 | 8/12/2014 | 435.040 | 725.320 | 2 | 11 | 11 | |
000190 | 20140801 | 8/12/2014 | 8/1/2014 | 8/12/2014 | 449.140 | 597.520 | 2 | 11 | 11 | |
000210 | 20140801 | 8/12/2014 | 8/1/2014 | 8/12/2014 | 498.680 | 597.520 | 2 | 11 | 11 | |
001700 | 20140801 | 8/12/2014 | 8/1/2014 | 8/12/2014 | 699.650 | 651.200 | 2 | 11 | 11 | |
001710 | 20140801 | 8/12/2014 | 8/1/2014 | 8/12/2014 | 638.800 | 592.040 | 2 | 11 | 11 | |
8/15/2014 | 8/6/2014 | 8/10/2014 | 638.800 | 592.040 | 2 | 9 | 9 |
SELECT"BILL_VBELN","BILL_FKDAT","BILL_KVGR1_1","BILL_FIL_PROFORMA_INV","BILL_KUNRG","BILL_KTGRD_1","BILL_VKORG_VBRK","BILL_INCO1","BILL_INCO2","BILL_PRCTR","BILL_POSNR","ROUTE","BILL_AUPOS","GET_DAYS","BILL_DATE_FY","BILL_DATE_FP","TO_DATE_EUDAT","TO_DATE_WADAT","DEL_DATE_CALC",
"TRAN_TIME","CA_BILL_REP_NETWR_COMP_CURR","CA_BILL_REP_WAVWR_COMP_CURR", MAX("NEW_DEL_DATE") AS"NEW_DEL_DATE"
FROM"_SYS_BIC"."pk-sample.productmanagement/XXXX"
WHERE"BILL_VBELN" = '9043128697'
GROUPBY"BILL_VBELN","BILL_FKDAT","BILL_KVGR1_1","BILL_FIL_PROFORMA_INV","BILL_KUNRG","BILL_KTGRD_1","BILL_VKORG_VBRK","BILL_INCO1","BILL_INCO2","BILL_PRCTR","BILL_POSNR","ROUTE","BILL_AUPOS","GET_DAYS","BILL_DATE_FY","BILL_DATE_FP","TO_DATE_EUDAT","TO_DATE_WADAT","DEL_DATE_CALC","TRAN_TIME","CA_BILL_REP_NETWR_COMP_CURR","CA_BILL_REP_WAVWR_COMP_CURR";
;
The code is correct, but I cannot achieve the desired output. I get below output.
VBELN | BILL_AUPOS | POSNR | GET_DAYS | TO_DATE_EUDAT | TO_DATE_WADAT | DEL_DATE_CALC | TRAN_TIME | CA_BILL_REP_NETWR_COMP_CURR | CA_BILL_REP_WAVWR_COMP_CURR | NEW_DEL_DATE |
9043128697 | 000010 | 20140801 | 2 | 8/12/2014 00:00:00 | 8/1/2014 00:00:00 | 11.00 | 11 | 642.88 | 482.16 | 8/12/2014 00:00:00 |
000060 | 20140801 | 2 | 8/12/2014 00:00:00 | 8/1/2014 00:00:00 | 11.00 | 11 | 181.13 | 89.06 | 8/12/2014 00:00:00 | |
000080 | 20140801 | 2 | 8/12/2014 00:00:00 | 8/1/2014 00:00:00 | 11.00 | 11 | 181.33 | 136.00 | 8/12/2014 00:00:00 | |
000090 | 20140801 | 2 | 8/12/2014 00:00:00 | 8/1/2014 00:00:00 | 11.00 | 11 | 725.32 | 435.04 | 8/12/2014 00:00:00 | |
000190 | 20140801 | 2 | 8/12/2014 00:00:00 | 8/1/2014 00:00:00 | 11.00 | 11 | 597.52 | 449.14 | 8/12/2014 00:00:00 | |
000210 | 20140801 | 2 | 8/12/2014 00:00:00 | 8/1/2014 00:00:00 | 11.00 | 11 | 597.52 | 498.68 | 8/12/2014 00:00:00 | |
001700 | 20140801 | 2 | 8/12/2014 00:00:00 | 8/1/2014 00:00:00 | 11.00 | 11 | 651.20 | 699.65 | 8/12/2014 00:00:00 | |
001710 | 20140801 | 4 | 8/12/2014 00:00:00 | 8/1/2014 00:00:00 | 20.00 | 20 | 1,184.08 | 1,277.60 | 8/10/2014 00:00:00 |
Please guide. The key figures are getting double, also the NEW_DEL_DATE picked up is wrong..