I have 2 tables.
The first returns the order number and the two-state times
Pedido TiempoPreparar TiempoAsignar
-------------------------------------------
P001 10 9
P002 20 5
P003 30 7
The second one, returns the times of 2 different states:
Pedido TiempoEmpacar TiempoEnruta
-------------------------------------------
P001 23 10
P001 14 21
P002 34 6
P003 16 5
P003 22 12
In table 2 there may be several records for a single order.
I am making the following query:
select A.*,B.TiempoEmpacar, TiempoEnruta
from tabla1 A
left join tabla2 B
on A.pedido = B.pedido
That returns this
Pedido TiempoPreparar TiempoAsignar TiempoEmpacar TiempoEnRuta
-------------------------------------------------------------
P001 10 9 23 10
P001 10 9 14 21
P002 20 5 34 6
P003 30 7 16 5
P003 30 7 22 12
But I need that for the duplicate values, it shows NULL, something like this:
Pedido TiempoPreparar TiempoAsignar TiempoEmpacar TiempoEnRuta
-------------------------------------------------------------
P001 10 9 23 10
P001 NULL NULL 14 21
P002 20 5 34 6
P003 30 7 16 5
P003 NULL NULL 22 12
That data took it to Quicksight (reporting tool), where I create a Dashboard, there I have the option to make PROMEDIOS, but if I have duplicate data it will take it into account, and that is what I want to avoid.
Thanks for your help.