all groups > sql server programming > september 2003 >
You're in the

sql server programming

group:

Need your help with a non trivial T-SQL


Re: Need your help with a non trivial T-SQL Bob Barrows
9/21/2003 11:58:05 AM
sql server programming: Does this meet your requirements? if not, please provide sample data and the
results desired from that sample data.

SELECT o.PersonOrderID, a.BookID, a.IsAvailable, a.Writer,
a.NumOfPages, a.Cost, a.Etc
FROM OB o INNER JOIN AB a ON
OP.BookID = AB.BookID
WHERE NOT EXISTS
(SELECT OB.PersonOrderID, AB.BookID
FROM OB INNER JOIN AB ON
OP.BookID = AB.BookID
WHERE AB.IsAvailable = 0 AND
OP.PersonOrderID = o.PersonOrderID AND
AB.BookID = a.BookID)

HTH,
Bob Barrows

[quoted text, click to view]


Need your help with a non trivial T-SQL Tomer
9/21/2003 6:15:20 PM
Hi All,

Please help me to realize if I can do it with T-SQL

I have two Tables:
1. Books Ordered by person -> OB
2. Available books -> AB

I need to create a query that will return all the column of the AB table,
BUT only when All the books ordered by a person are available
(IsAvailable=1).

Example for the structure:

OB
PersonOrderID int (Key)
BookID int (Key)
---------------------------
AB
BookID int (Key)
IsAvailable bit
Writer nvarchar(32)
NumOfPages int
Cost float
Etc.


Can you please make a draft of a T-SQL that will do this work?

Thanks!
Tomer



AddThis Social Bookmark Button