I don't know if this'll work or not, but you might try :

SELECT DISTINCT(Part & Dept) FROM Routing ORDER BY Part,Dept

I tried something similar on some of my data and I think this approach might
help you out.

Later,
Steve in Memphis


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of William Carson
Sent: Wednesday, May 08, 2002 3:00 PM
To: [EMAIL PROTECTED]
Subject: SQL Question


Is there a simple (or complex for that matter) SQL statement for the
following scenario?

Let�s say I have a table called Routing with columns Part (Part Number),
Dept (Department), Oper (Operation) and Seq (Sequence) with the following
data:
            Part                  Dept                 Oper
Seq
            ABC                 1                      1.1
1
            ABC                 1                      1.2
2
            ABC                 2                      2.1
3
            ABC                 2                      2.3
4
            ABC                 1                      1.1
5
            ABC                 1                      1.4
6
            ABC                 15                     15.2
7
            ABC                 15                     15.6
8
            ABC                 15                     15.9
9
I am looking for an SQL statement that will return the list of departments
that is goes through and the order in which it goes through them.  In other
words, I want:
            Part                  Dept
            ABC                 1
            ABC                 2
            ABC                 1
            ABC                 15
I tried:
            SELECT Part,Dept,MIN(Oper) FROM Routing GROUP BY Part,Dept ORDER
BY Seq
But I guess in a GROUP BY you can�t ORDER BY a column not in the SELECT.

Does anyone have any suggestions?  Even if it takes more than one SQL
statement or view.

Thank in advance.

Bill

================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: INTRO rbase-l
================================================
TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: UNSUBSCRIBE rbase-l
================================================
TO SEARCH ARCHIVES:
http://www.mail-archive.com/rbase-l%40sonetmail.com/

Reply via email to