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

Not very good at SQL, trying to query multiple tables

From: <ture_at_turedata.se>
Date: 1 Aug 2006 06:36:07 -0700
Message-ID: <1154439367.201288.203920@m73g2000cwd.googlegroups.com>


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 Received on Tue Aug 01 2006 - 08:36:07 CDT

Original text of this message

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