Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
omarlq20
Contributor II
Contributor II

consulta, información por fecha

Hello

Can you help me with the following problem that I have,

I need the following, I have 2 tables which will relate to the product in tabla_1 have an end date and the tabla_2 have the time and money to take, when the condition is tabla_1.fecha_final> tabla_2. take the first record date that meets this condition, tabla_2.fecha, tabla_2.precio, but if the tabla_2.fecha has 2 records with the same date and time to take the last entered x desc order.

This is the SQL statement used in

select top 1 tabla_2.fecha, tabla_2.precio from tabla_2 inner join on tabla_1 tabla_1.producto and tabla_1.fecha tabla_2.producto => tabla_2.fecha order by date desc

Deputy qvw file I'm using model and excel file, which is the result that should be me.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Hola,

Me podrían ayudar con el siguiente problema que tengo,

Necesito lo siguiente, tengo 2 tablas las cuales se van a relacionar por el producto, en la tabla_1 tengo una fecha de termino y en la tabla_2 tengo la fecha y el precio que debe tomar, la condición es cuando la tabla_1.fecha_final > tabla_2.fecha tome el primer registro que cumpla con esta condición, tabla_2.fecha, tabla_2.precio, pero si en caso la tabla_2.fecha tiene 2 registros con la misma fecha y hora tome el ultimo ingresado x orden desc.

esta es la sentencia usada en SQL

select top 1 tabla_2.fecha, tabla_2.precio from tabla_2 inner join tabla_1 on tabla_2.producto = tabla_1.producto and tabla_1.fecha > tabla_2.fecha order by fecha desc

Adjunto el archivo de qvw que estoy usando de modelo y el archivo de excel, el cual es el resultado que me debería quedar.

Miguel Angel BaeyensMarc Littmanjive-admin

3 Replies
Not applicable

Hola Omar

Estoy trabajando en el caso y me pregunto en el caso del Dato B

31/05/2013B21/05/2013 12:09:00 PM13

Que una vez filtrado por la Fecha quedan los dos registros con la misma FechaFin (21/05/2013 12:09:00 PM) cual seria el criterio, el precio mayor?

    B, 21/05/2013 12:09:00 PM, 12

    B, 21/05/2013 12:09:00 PM, 13

omarlq20
Contributor II
Contributor II
Author

Hola Marcos,

Debería tomarse el precio mayor, es decir

B, 21/05/2013 12:09:00 PM, 12

B, 21/05/2013 12:09:00 PM, 13 (Valor a tomar)

Not applicable

Estimado Omar

Adjunto a esta respuesta tu QVW con el resultado final, en resumen hace los siguientes pasos:

1. Une las dos tablas

2. Filtra los datos de esta tabla unida para descartar las fechas menores tabla_1.fecha_final > tabla_2.fecha

3. De esta taba resultante escoje las fechas máximas tabla_2.fecha por producto

4. Marca los repetidos (tabla_2.fecha iguales por producto) si existen del resultado anterior

5. Filtra descartando los marcados (Repetidos)