On 12/9/22 12:32, Shaozhong SHI wrote:
> That works well.
>
> I just wonder whether we can tell Tom or Tim has worked in more than 1
> department. Apparently, PostgreSQL does not allow count(distinct
> department) when window function is used.
>
> Given this data set, can we do something like count(distinct) to
> provide an answer to how many different department someone has worked in?
>
> Regards,
>
> David
Use the working query in a CTE and simply do the count(distinct
department) on that, else there's no good place to put the number of
departments per person.
Pretty sure you've been asked before but Please don't top post.