Hi All!
Is it possible in Paradox to use SQL queries with subqueries in the form of
Select [...]
From (Select [...] From [...] )
Where [...]
I believe this is standard SQL syntax, but it seems to be unsupported in Paradox.
What I'm trying to do is the following (maybe you have other ideas how to do that). I have table of Orders, and for each order: table with Amounts that are to be paid and table with Payments. I want to find the orders that are not paid in full, i.e. for which sum(Payment)<Sum(Amount)
Here's the code that gives Order No, sum(Payment) and sum(Amount):
SELECT Orders."Order No", SUM(Orditem."Amount"
AS SUM_OF_Amount, SUM(PAYMENTS."Payment"
AS SUM_OF_Payment
FROM ":data:Orders.DB" Orders
INNER JOIN ":data:Orditem.DB" Orditem
ON (Orders."Order No" = Orditem."Order No"
INNER JOIN ":data
AYMENTS.DB" PAYMENTS
ON (Orders."Order No" = PAYMENTS."Order No"
GROUP BY Orders."Order No"
I can save this table to file and do:
Select * from MyTable
Where Sum_Of_Amount<Sum_Of_Payment
But this is not "nice", as it takes intermediate step. I believe there's a way to do it without saving results and quering them again - like querying the subquery.
I tried to put the first query in the second instead of MyTable, but it gives syntax error. Am I doing something wrong?
Thank You
Is it possible in Paradox to use SQL queries with subqueries in the form of
Select [...]
From (Select [...] From [...] )
Where [...]
I believe this is standard SQL syntax, but it seems to be unsupported in Paradox.
What I'm trying to do is the following (maybe you have other ideas how to do that). I have table of Orders, and for each order: table with Amounts that are to be paid and table with Payments. I want to find the orders that are not paid in full, i.e. for which sum(Payment)<Sum(Amount)
Here's the code that gives Order No, sum(Payment) and sum(Amount):
SELECT Orders."Order No", SUM(Orditem."Amount"
FROM ":data:Orders.DB" Orders
INNER JOIN ":data:Orditem.DB" Orditem
ON (Orders."Order No" = Orditem."Order No"
INNER JOIN ":data
ON (Orders."Order No" = PAYMENTS."Order No"
GROUP BY Orders."Order No"
I can save this table to file and do:
Select * from MyTable
Where Sum_Of_Amount<Sum_Of_Payment
But this is not "nice", as it takes intermediate step. I believe there's a way to do it without saving results and quering them again - like querying the subquery.
I tried to put the first query in the second instead of MyTable, but it gives syntax error. Am I doing something wrong?
Thank You