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: Beginners SQL Puzzle??

Re: Beginners SQL Puzzle??

From: Sybrand Bakker <postmaster_at_sybrandb.demon.nl>
Date: Fri, 17 Sep 1999 20:25:00 +0200
Message-ID: <937592767.29627.0.pluto.d4ee154e@news.demon.nl>


Hi John,

Well you may meet with remarks like
Is this your homework...
Anyway, it's Friday evening, on working days I probably wouldn't have answered.
Here is a solution in sql*plus.

column classid noprint
break on classid nodup skip 2
compute sum of minutes on classid
select leadername, classid, type, minutes from table1, table2
where table1.classid = table2.classid;

Hth,

--
Sybrand Bakker, Oracle DBA
John P <john_at_sessio.com> wrote in message news:604B2A6B5616F41C.7325921A7576393D.82B33A45BEEFE61E_at_lp.airnews.net...
> I hope it's OK to ask beginner SQL questions. I just can't seem to
> get my brain to twist in the right direction for this one!
>
> I've got 2 tables (simplified):
>
> Table1
> classid type minutes
> 1 leader 10
> 1 student 3
> 1 student 4
> 1 student 2
> 2 leader 12
> 2 student 7
> 2 student 1
> and so on ....
>
> Table 2
> classid leadername
> 1 Bob
> 2 Sally
> and so on ....
>
>
> What I'm trying to get is a report that looks like:
>
> Bob student 3 minutes
> Bob student 4 minutes
> Bob student 2 minutes
> Total 9 minutes
>
> Sally student 7 minutes
> Sally student 1 minutes
> Total 8 minutes
>
>
> The main thing I can't seem to get to work is to get 'Bob' at the
> start of each line and a total for that classid.
>
> THANKS!
Received on Fri Sep 17 1999 - 13:25:00 CDT

Original text of this message

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