Re: SQL question

From: Joe Celko <71062.1056_at_compuserve.com>
Date: 2000/05/13
Message-ID: <8fk00q$16k$1_at_nnrp1.deja.com>#1/1


Opps:

2) Build an auxiliary table of sequential numbers

CREATE TABLE Sequence (i INTEGER NOT NULL PRIMARY);  INSERT INTO Sequence VALUES (1), (2), ... , (n);

SELECT R1.rack_nbr, Q1.i AS missing_position   FROM Racks AS R1, Sequence AS Q1
 WHERE Q1.i <= R1.size
   AND NOT EXISTS

       (SELECT *
          FROM Samples AS S1
         WHERE Q1.i = S1.position_in_rack
           AND S1.rack_nbr = R1.rack_nbr);

I should not post things without sleeping first.

--CELKO--
Joe Celko, SQL and Database Consultant

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Sat May 13 2000 - 00:00:00 CEST

Original text of this message