From: | Victor Yegorov <vyegorov(at)gmail(dot)com> |
---|---|
To: | jj08 <jj08(at)drivehq(dot)com> |
Cc: | pgsql-sql(at)lists(dot)postgresql(dot)org |
Subject: | Re: RE:Re: A complex SQL query |
Date: | 2019-09-07 21:33:28 |
Message-ID: | CAGnEboib=bKnJsW9Ho_A0-fBoCzb2cxQp+oXHNxmoBrro+dS3w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
сб, 7 сент. 2019 г. в 21:23, jj08 <jj08(at)drivehq(dot)com>:
> To Janis or other members of the forum:
>
> My sample table contains other columns as well.
>
> One of the columns that I did not include in my first message is
> "position".
> The last table has been modified as follows:
>
> +--------+----------+------------+------------------------+
> | usr_id | employer | position + start_date | end_date |
> +--------+----------+------------+------------------------+
> | A | Goo | CTO | | 201904 |
> | A | Micro | Mgr | 201704 | 201903 |
>
> | B | Micro | Engg_Mgr | 201706 | - |
> | B | Goo | Researcher | 201012 | 201705 |
> | B | Micro | Postdoc | 201001 | 201011 |
> +--------+----------+------------+------------------------+
>
SELECT DISTINCT ON (usr_id)
*
FROM employment
WHERE employer='Micro'
ORDER BY usr_id, start_date DESC;
--
Victor Yegorov
From | Date | Subject | |
---|---|---|---|
Next Message | jj08 | 2019-09-08 02:09:45 | RE:Re: RE:Re: A complex SQL query |
Previous Message | jj08 | 2019-09-07 18:23:20 | RE:RE:Re: A complex SQL query |