Let me get this straight.  You want to process only new orders that do
not have an associated "cancelled" record, right?


If so, you could use a self-join.  A self-join is where you a table to
itself.  To do so, you must specify different table aliases (T1 and T2
in the code below).


It would look something like this:


SELECT T1.OrderNbr, T1.OrderThing
FROM Orders T1 INNER JOIN Order T2 ON T1.OrderNbr = T2.OrderNbr
WHERE T2.Status <> 0


M!ke

  _____  

From: Tony Weeg [mailto:[EMAIL PROTECTED]
Sent: Friday, July 23, 2004 8:31 AM
To: CF-Talk
Subject: sql question


sql gurus...got a question.

lets say i have a table, and in that table there could be 2 rows
for
one order coming from crm system.. the first row, has a status
of 1,
meaning new, and process it now.  the second row, would match on
a
order number column, but a status of 0...meaning cancelled.  i
want to
show all rows from the table that dont have a matching 0 status
row.

is this possible in 1 query?

something like this..

select *
from table
where status = 1 and status <> 0

:) i know this is way off, but im not sure how to compare, where
i
have a matching column, but an opposing status of 0 with the
same
order id.

thanks :)

--
tony

Tony Weeg
human.
email: tonyweeg [at] gmail [dot] com
blog: http://www.revolutionwebdesign.com/blog/

Check out http://www.antiwrap.com to send websites to your
friends.
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to