Skip site navigation (1) Skip section navigation (2)

making two columns out of one

From: Frank Bax <fbax(at)execulink(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: making two columns out of one
Date: 2000-09-11 13:34:47
Message-ID: 3.0.6.32.20000911093447.01fcb4c0@execulink.com (view raw or flat)
Thread:
Lists: pgsql-sql
I've got a table containing some timesheet data.
Fields are emp, earncode, lo_shift, hi_shift.

SELECT emp, sum(hi_shift - lo_shift) as reghrs from timesheet 
where earncode in ('R', 'C', 'X') order by emp

will give me all the regular hours

SELECT emp, sum(hi_shift - lo_shift) as ovrhrs from timesheet 
where earncode not in ('R', 'C', 'X') order by emp

will give me all the overtime hours.

How do I combine these to get one result set with emp, reghrs, ovrhrs on
each row.

Frank




________________________________________________________
                           1stUp.com - Free the Web
   Get your free Internet access at http://www.1stUp.com

Responses

pgsql-sql by date

Next:From: Palle GirgensohnDate: 2000-09-11 13:51:23
Subject: Re: need asap: bg_BG locale for FreeBSD
Previous:From: Trewern, BenDate: 2000-09-11 12:27:48
Subject: Tree structure

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group