gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] Getting Canadian drug data into FreeDiams


From: Karsten Hilbert
Subject: Re: [Gnumed-devel] Getting Canadian drug data into FreeDiams
Date: Fri, 19 Feb 2010 22:40:14 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

On Fri, Feb 19, 2010 at 03:12:08AM -0800, Jim Busser wrote:

> because it wants only a single record defining the drug's availability, 
> whereas Health Canada data provides a historical record of notices. 
> Accordingly there exist multiple values of
> 
>       CURRENT_STATUS_FLAG
> 
> with varying ages of records, per drug. Presumably I need to make the SELECT 
> command ignore values *except* for the newest per drug else some way to first 
> delete the non-newest records per drug.

Ah, now I understand. This is typically done with either a
GROUP BY/HAVING or a self-join.

select
        *
FROM
        this_table as level1
WHERE
        level1.date = (select max(date) from this_table as level2 where 
level1.drug_code = level2.drug_code)
                and
        ... other conditions ...
;

Does that help ?

Karsten
-- 
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346




reply via email to

[Prev in Thread] Current Thread [Next in Thread]