Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL help needed

Re: SQL help needed

From: Mark Styles <lambicm_at_yahoo.com>
Date: Mon, 28 Sep 1998 15:56:42 GMT
Message-ID: <360fb004.27819282@news.intra.bt.com>


Mon, 28 Sep 1998 16:09:49 +0100, "AJ Benn" <a.j.benn_at_x400.icl.co.uk> rambled:

I haven't tested this, but give it a go:

select
  job,

  sum(decode(sign(sal-1000),-1,1,0)) low,
  sum(decode(sign(sal-1000),-1,0,decode(sign(sal-3000),1,0,1))) med,
  sum(decode(sign(sal-1000),1,1,0)) high
from emp
group by job;

>Using the Oracle example table 'EMP', I want to produce a query that will
>show me the number of employees whose Salary falls within a particular range
>(i.e less than 1000, between 1000 and 3000, and then greater than 3000), and
>then grouped by Job. The output I want is as follows:-
>
>Job $ <1000 $ 1000-3000 $ 3000+
>======= ==== ======== =====
>Clerk 2 2
>Salesman 4
>Manager 3
>Analyst 2
>President
>1
>
>Anyone offer any help on this knotty little problem ?
>
>Many thanks
>Andy
>
>(Sorry if the table isn't lined up very well)
>
>

Mark Styles
Spam my account, lose your account. Clear enough? Religious tolerance is an oxymoron. Received on Mon Sep 28 1998 - 10:56:42 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US