Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Please, can someone tell me where im wrong
ANALISE_TMP:
LOAD
ID_LEITURA,
NAME_SYSTEM,
NAME_GROUP,
NEIGHB_SYSTEM,
CITY_SYSTEM,
OID_METER,
NAME_TYPE_METER,
TYPE_CONSTANT,
NAME_UC,
ADDRESS_BLOCK_UC,
DATE_READ AS DIA0,
VALUE_READ,
VALUE_READ*TYPE_CONSTANT AS LEITURA_FINAL,
IF(OID_METER=PEEK(OID_METER) AND FLOOR(DATE_READ)=FLOOR(TODAY()),PEEK(VALUE_READ)) * TYPE_CONSTANT)-(VALUE_READ*TYPE_CONSTANT) AS CONSUMODIA0,
IF(OID_METER=PEEK(OID_METER) AND FLOOR(DATE_READ)=FLOOR(TODAY()-1),PEEK(VALUE_READ)) * TYPE_CONSTANT)-(VALUE_READ*TYPE_CONSTANT) AS CONSUMODIA1,
IF(OID_METER=PEEK(OID_METER) AND FLOOR(DATE_READ)=FLOOR(TODAY()-2),PEEK(VALUE_READ)) * TYPE_CONSTANT)-(VALUE_READ*TYPE_CONSTANT) AS CONSUMODIA2
RESIDENT TMP2
ORDER BY OID_METER, DATE_READ DESC;
I got this message:
Ocorreram os seguintes erros:
Syntax error, missing/misplaced FROM:
May be try this:
If(OID_METER = Peek(OID_METER) and Floor(DATE_READ) = Floor(Today()), (Peek(VALUE_READ) - VALUE_READ) * TYPE_CONSTANT) as CONSUMODIA0,
I think that error means that if you are doing an order by, you have to load from a qvd or external source, not resident load?
May be try this:
If(OID_METER = Peek(OID_METER) and Floor(DATE_READ) = Floor(Today()), (Peek(VALUE_READ) - VALUE_READ) * TYPE_CONSTANT) as CONSUMODIA0,
Hey Sunny !
That works a litle bit, now im not have that red mark anymore, but still have the same erro when compile
ANALISE_TMP:
LOAD
ID_LEITURA,
NAME_SYSTEM,
NAME_GROUP,
NEIGHB_SYSTEM,
CITY_SYSTEM,
OID_METER,
NAME_TYPE_METER,
TYPE_CONSTANT,
NAME_UC,
ADDRESS_BLOCK_UC,
DATE_READ AS DIA0,
VALUE_READ,
If(OID_METER= Peek(OID_METER) and Floor(DATE_READ)= Floor(Today()),(Peek(VALUE_READ)- VALUE_READ) * TYPE_CONSTANT) as CONSUMODIA0,
If(OID_METER= Peek(OID_METER) and Floor(DATE_READ)= Floor(Today()-1),(Peek(VALUE_READ)- VALUE_READ) * TYPE_CONSTANT) as CONSUMODIA1,
If(OID_METER= Peek(OID_METER) and Floor(DATE_READ)= Floor(Today()-2),(Peek(VALUE_READ)- VALUE_READ) * TYPE_CONSTANT) as CONSUMODIA2,
RESIDENT TMP2
ORDER BY OID_METER, DATE_READ DESC;
Ocorreram os seguintes erros:
Syntax error, missing/misplaced FROM: ANALISE_TMP:
No Sarah, below i have the original code and it works fine. But im trying to improve.
They use 3 times the same code and i want to do replace with a multiple IF
ANALISE_TMP:
LOAD
ID_LEITURA,
NAME_SYSTEM,
NAME_GROUP,
NEIGHB_SYSTEM,
CITY_SYSTEM,
OID_METER,
NAME_TYPE_METER,
TYPE_CONSTANT,
NAME_UC,
ADDRESS_BLOCK_UC,
DATE_READ AS DIA0,
VALUE_READ AS VALOR0,
VALUE_READ*TYPE_CONSTANT AS LEITURA_INICIAL_DIA0,
IF(OID_METER=PEEK(OID_METER),PEEK(DIA0)) AS DATA_HORA_LEITURA_FINAL_DIA0,
IF(OID_METER=PEEK(OID_METER),PEEK(VALOR0)) * TYPE_CONSTANT AS LEITURA_FINAL_DIA0,
(IF(OID_METER=PEEK(OID_METER),PEEK(VALOR0)) * TYPE_CONSTANT)-(VALUE_READ*TYPE_CONSTANT) AS CONSUMODIA0
RESIDENT TMP2
where FLOOR(DATE_READ)=FLOOR(TODAY())
ORDER BY OID_METER, DATE_READ DESC;
There is a comma after your last field "CONSUMODIA2" which needs to be removed.
- Marcus
Indeed Marcus, thank you.
@SUNNY But why the code works only because i lower case the variables?
I did change some parenthesis in your script line
Mine
If(OID_METER = Peek(OID_METER) and Floor(DATE_READ) = Floor(Today()), (Peek(VALUE_READ) - VALUE_READ) * TYPE_CONSTANT) as CONSUMODIA0,
Vs.
Yours
IF(OID_METER=PEEK(OID_METER) AND FLOOR(DATE_READ)=FLOOR(TODAY()),PEEK(VALUE_READ)) * TYPE_CONSTANT)-(VALUE_READ*TYPE_CONSTANT) AS CONSUMODIA0,
Right, Thank you again