Re: UNION question

From: "Hartman, Matthew" <Matthew(dot)Hartman(at)krcc(dot)on(dot)ca>
To: "Brandon Metcalf" <brandon(at)geronimoalloys(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: UNION question
Date: 2009-07-10 16:23:42
Message-ID: 366642367C5B354197A1E0D27BC175BD02259890@KGHMAIL.KGH.ON.CA
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-
> owner(at)postgresql(dot)org] On Behalf Of Brandon Metcalf
> Sent: Friday, July 10, 2009 12:16 PM

Change it to this:

> SELECT t.name AS machine_type_name,
> j.workorder,
> round(sum(EXTRACT(epoch FROM(j.clockout-
> j.clockin))/3600/w.quantity_made)::numeric,2)
> AS avgtime
> NULL AS employees
> FROM jobclock j
> JOIN employee e ON e.employee_id=j.employee_id
> JOIN machine m ON m.machine_id=j.machine_id
> JOIN machine_type t ON t.machine_type_id=m.machine_type_id
> JOIN workorder w ON w.workorder=j.workorder
> JOIN part p ON p.part_id=w.part_id
> WHERE p.part_id=379
> UNION
> SELECT t.name AS machine_type_name,
> NULL AS workorder,
> h.time AS avgtime,
> employees
> FROM part_time_historical h
> JOIN machine_type t ON
> t.machine_type_id=h.machine_type_id
> WHERE h.part_id=379 AND h.machine_type_id=1
> WHERE t.machine_type_id=1
> GROUP BY t.name,j.workorder
> ORDER BY avgtime

Matthew Hartman
Programmer/Analyst
Information Management, ICP
Kingston General Hospital.now.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hartman, Matthew 2009-07-10 16:27:44 Re: UNION question
Previous Message Brandon Metcalf 2009-07-10 16:16:10 UNION question