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: Not very good at SQL, trying to query multiple tables

Re: Not very good at SQL, trying to query multiple tables

From: DA Morgan <damorgan_at_psoug.org>
Date: Tue, 01 Aug 2006 08:22:22 -0700
Message-ID: <1154445743.79218@bubbleator.drizzle.com>


ture_at_turedata.se wrote:
> I know what I have and what I want but not how to get there. Can
> someone suggest a SQL SELECT statement to give the desired result:
>
> Some background info:
> I have four tables which contains some data about paper mill
> production.
> The paper is produced on wide and long rolls of paper called REELS.
> After a REEL is produced, it is re-rolled and cut into shorter and less
> wide SETS of ROLLS. There is also a table called RUNMASTER which
> contains some information for a production period where several REELS
> are produced.
>
> A REEL can typically be 6.7 meters wide and contain 27,222 meters of
> paper.
> The ROLLS from such a REEL could be:
> SET 1: 10,000 meters long, 2.10, 2.10 and 2.10 meters wide. (0.4 meters
> width waste)
> SET 2: 10,000 meters long, 2.10, 2.10 and 2.10 meters wide. (0.4 meters
> width waste)
> SET 3: 7,000 meters long, 3.20 and 3.20 meters wide (0.3 meters width
> waste)
> (222 meters lenghth waste)
>
> RUNMASTER
> runorder
> reelwidth
>
> REELMASTER (several reels per runorder)
> runorder
> deptno
> reelno
> grade
> gradeweight
> reellength
>
> SETMASTER (several sets per reel)
> reelno
> setno
> setlength
>
> ROLLMASTER (several rolls per set)
> reelno
> rollno
> rollwidth
>
> This is the result I want:
> For REELMASTER.DEPTNO = 6 and REELMASTER.BEGTIME >=2006-07-01 and
> REELMASTER.BEGTIME <2006-08-01
>
> Grouped for each REELNO and SET
>
> REELNO, SETNO, to_date(BEGTIME), GRADE, GRADEWEIGHT, REELLENGTH,
> SETLENGTH, REELWIDTH, sum(ROLLWIDTH)
>
> The resulting rows for the example reel I mentioned before would be:
> 123456, 1, 2006-07-01, GRADEX, 150, 27222, 10000, 6,7, 6.3
> 123456, 2, 2006-07-01, GRADEX, 150, 27222, 10000, 6,7, 6.3
> 123456, 3, 2006-07-01, GRADEX, 150, 27222, 7000, 6,7, 6.4
>
> Best regards,
> Ture Magnusson
> Karlstad, Sweden

If you want someone to do your work for you please provide the DDL to create the table, the insert statements, and example output.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Tue Aug 01 2006 - 10:22:22 CDT

Original text of this message

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