Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I tried for country wise sales , if two rows have similar country's data ;
But I am not sure why it is not working 'USA' ? in 'TABLE BOX'
TABLE BOX :
Did you forget to may be add Order By Statement here?
TEMP1:
LOAD * INLINE
[
COUNTRY, PRODUCT, SALES
MEXICO, A, 10000
ENGLAND, B, 100
USA, C, 4545
FRANCE, A, 7778
FRANCE,A, 8000
USA, B, 99999
INDIA, C, 12120
]
;
NoConcatenate
TEMP2:
LOAD COUNTRY, PRODUCT, SALES ,
if(COUNTRY=PREVIOUS(COUNTRY),PREVIOUS(SALES)+SALES, NULL()) AS COUNTRYWISESALES
Resident TEMP1
Order By COUNTRY; //or Order By COUNTRY, PRODUCT asc/desc;
DROP TABLE TEMP1;
Did you forget to may be add Order By Statement here?
TEMP1:
LOAD * INLINE
[
COUNTRY, PRODUCT, SALES
MEXICO, A, 10000
ENGLAND, B, 100
USA, C, 4545
FRANCE, A, 7778
FRANCE,A, 8000
USA, B, 99999
INDIA, C, 12120
]
;
NoConcatenate
TEMP2:
LOAD COUNTRY, PRODUCT, SALES ,
if(COUNTRY=PREVIOUS(COUNTRY),PREVIOUS(SALES)+SALES, NULL()) AS COUNTRYWISESALES
Resident TEMP1
Order By COUNTRY; //or Order By COUNTRY, PRODUCT asc/desc;
DROP TABLE TEMP1;
previous() will need to be used in a sorted file.
try this
TEMP1:
LOAD * INLINE
[
COUNTRY, PRODUCT, SALES
MEXICO, A, 10000
ENGLAND, B, 100
USA, C, 4545
FRANCE, A, 7778
FRANCE,A, 8000
USA, B, 99999
INDIA, C, 12120
]
;
NoConcatenate
TEMP2:
LOAD *
Resident TEMP1
order by COUNTRY, PRODUCT;
DROP TABLE TEMP1;
NoConcatenate
TEMP3:
LOAD COUNTRY, PRODUCT, SALES ,
if(COUNTRY=PREVIOUS(COUNTRY),PREVIOUS(SALES)+SALES, NULL()) AS COUNTRYWISESALES
Resident TEMP2;
DROP TABLE TEMP2;
thanks ....a lot