Re: Obtener un resultado extraño.

From: Hellmuth Vargas <hivs77(at)gmail(dot)com>
To: Nahum Castro <nahumcastro(at)gmail(dot)com>
Cc: Horacio Miranda <hmiranda(at)gmail(dot)com>, pgsql-es-ayuda <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Obtener un resultado extraño.
Date: 2019-11-14 13:33:22
Message-ID: CAN3Qy4pDLMW=x1y4q8FuBkES6DKVhNKpFxR_oK4Gh6BnBy8zxQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Buenos días

propongo algo similar a esto:

select Medicamento,Dosis,Diluyente,Volumen,Laboratorio,case when
aparicion=1 then Lote_Medicamento else '' end as
Lote_Medicamento,Lote_Preparacion,Fecha_Preparacion,Fecha_Caducidad
from (
select
Medicamento,Dosis,Diluyente,Volumen,Laboratorio,Lote_Medicamento,row_number()
over (partition by Lote_Medicamento order by Lote_Medicamento) as
aparicion,Lote_Preparacion,Fecha_Preparacion,Fecha_Caducidad
from (
values
('Trastuzumab','440 mg','S.S.F
0.899999976%','250','Roche','N7367B01B3117','OP201911132','2019-11-13','15-Nov-2019
16:11:23'),
('Docetaxel','50 mg','Dextrosa 5%','500','Synthon
','CQ18007B','OP201911133','2019-11-13','14-Nov-2019 16:11:23'),
('Docetaxel','20 mg','Dextrosa 5%','500','Synthon
','CQ18007B','OP201911133','2019-11-13','14-Nov-2019 16:11:23'),
('Docetaxel','55 mg','Dextrosa 5%','500','Synthon
','CQ18007B','OP201911133','2019-11-13','14-Nov-2019 16:11:23')
) as
a(Medicamento,Dosis,Diluyente,Volumen,Laboratorio,Lote_Medicamento,Lote_Preparacion,Fecha_Preparacion,Fecha_Caducidad)

) as j

que entrega el siguiente resultado:

medicamento | dosis | diluyente | volumen | laboratorio |
lote_medicamento | lote_preparacion | fecha_preparacion | fecha_caducidad
-------------+--------+--------------------+---------+-------------+------------------+------------------+-------------------+----------------------
Docetaxel | 50 mg | Dextrosa 5% | 500 | Synthon |
CQ18007B | OP201911133 | 2019-11-13 | 14-Nov-2019
16:11:23
Docetaxel | 20 mg | Dextrosa 5% | 500 | Synthon |
| OP201911133 | 2019-11-13 | 14-Nov-2019 16:11:23
Docetaxel | 55 mg | Dextrosa 5% | 500 | Synthon |
| OP201911133 | 2019-11-13 | 14-Nov-2019 16:11:23
Trastuzumab | 440 mg | S.S.F 0.899999976% | 250 | Roche |
N7367B01B3117 | OP201911132 | 2019-11-13 | 15-Nov-2019
16:11:23
(4 rows)

El jue., 14 de nov. de 2019 a la(s) 07:59, Nahum Castro (
nahumcastro(at)gmail(dot)com) escribió:

> Es antinatura los se, pero solo es una salida para un reporte. Los datos
> estan correctos.
>
> Saludos.
> Nahum
>
> El mié., 13 de nov. de 2019 a la(s) 22:32, Horacio Miranda (
> hmiranda(at)gmail(dot)com) escribió:
>
>> Vas a perder información sí haces eso.
>>
>> Estas seguro que eso es lo que necesitas hacer ?
>> On 14/11/2019 3:51 PM, Nahum Castro wrote:
>>
>> Hola a todos.
>>
>> Tengo una consulta qe me regresa lo siguiente:
>> Medicamento|Dosis |Diluyente |Volumen
>> (ml)|Laboratorio|Lote/Medicamento|Lote Preparación|Fecha Preparación|Fecha
>> Caducidad |
>>
>> -----------|------|------------------|------------|-----------|----------------|----------------|-----------------|--------------------|
>> Trastuzumab|440 mg|S.S.F 0.899999976%| 250|Roche
>> |N7367B01B3117 |OP201911132 | 2019-11-13|15-Nov-2019 16:11:23|
>> Docetaxel |50 mg |Dextrosa 5% | 500|Synthon |CQ18007B
>> |OP201911133 | 2019-11-13|14-Nov-2019 16:11:23|
>> Docetaxel |20 mg |Dextrosa 5% | 500|Synthon |CQ18007B
>> |OP201911133 | 2019-11-13|14-Nov-2019 16:11:23|
>> Docetaxel |55 mg |Dextrosa 5% | 500|Synthon |CQ18007B
>> |OP201911133 | 2019-11-13|14-Nov-2019 16:11:23|
>>
>> Necesito hacer una consulta que retorne lo siguiente:
>> Medicamento|Dosis |Diluyente |Volumen
>> (ml)|Laboratorio|Lote/Medicamento|Lote Preparación|Fecha Preparación|Fecha
>> Caducidad |
>>
>> -----------|------|------------------|------------|-----------|----------------|----------------|-----------------|--------------------|
>> Trastuzumab|440 mg|S.S.F 0.899999976%| 250|Roche
>> |N7367B01B3117 |OP201911132 | 2019-11-13|15-Nov-2019 16:11:23|
>> Docetaxel |50 mg |Dextrosa 5% | 500|Synthon |CQ18007B
>> |OP201911133 | 2019-11-13|14-Nov-2019 16:11:23|
>> Docetaxel |20 mg |Dextrosa 5% | 500|Synthon |
>> |OP201911133 | 2019-11-13|14-Nov-2019 16:11:23|
>> Docetaxel |55 mg |Dextrosa 5% | 500|Synthon |
>> |OP201911133 | 2019-11-13|14-Nov-2019 16:11:23|
>>
>> El lote solo debe aparecer una vez en los renglones repetidos.
>>
>> Ya le di muchas vueltas y no encuentro la respuesta.
>>
>> ¿Conocen alguna forma de hacerlo?
>>
>> Gracias mil
>>
>> --
>> *Nahum Castro González*
>> Blvd. Perdigón 214, Brisas del Lago.
>> CP 37207
>> León, Guanajuato, México
>> Tel (477)1950304
>> Cel (477)1274694
>>
>>
>
> --
> *Nahum Castro González*
> Blvd. Perdigón 214, Brisas del Lago.
> CP 37207
> León, Guanajuato, México
> Tel (477)1950304
> Cel (477)1274694
>

--
Cordialmente,

Ing. Hellmuth I. Vargas S.
Esp. Telemática y Negocios por Internet
Oracle Database 10g Administrator Certified Associate
EnterpriseDB Certified PostgreSQL 9.3 Associate

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Jose Mercedes Venegas Acevedo 2019-11-14 16:22:17 Soporte de versiones de postgres
Previous Message Nahum Castro 2019-11-14 12:59:11 Re: Obtener un resultado extraño.