all groups > sql server mseq > march 2005 >
You're in the

sql server mseq

group:

Help with Query


Help with Query Newbie
3/18/2005 1:01:23 PM
sql server mseq:
Is it possible to do this all in one stored procedure?

I have 3 separate queries which returns all the correct records with
Stockcode being the field to join

Q1 is my main query from which I want to return all the records.
Q2 and Q3 return records but not every record in Query1 will have record in
Q2 and Q3.

i.e. SELECT Q1.*, Q2.Sales, Q3.Receipts
FROM Q1 LEFT JOIN Q2 ON Q1.StockCode = Q2.StockCode LEFT JOIN Q3 ON
Q1.StockCode = Q3.StockCode
WHERE Q1.Qty > 0 AND Q2.Sales <= (Q1.Qty * 0.3)

In subqueries I know you can use a subquery in the FROM clause is it
possible to have a subquery as part of the JOIN syntax?

Re: Help with Query Newbie
3/18/2005 1:21:28 PM
Worked it out I think
[quoted text, click to view]

AddThis Social Bookmark Button