Board index » delphi » sql union

sql union

Hello,

Maybe someone knows how to transfer parameter from one query to other in
union

---
SELECT Person.ID as TTT,Person.Name, Sum(Sales.TotalPrice) AS
SumOfTotalPrice
FROM Person INNER JOIN Sales ON Person.ID = Sales.PersonID
WHERE (((Person.ID)=19))
GROUP BY Person.ID,Person.Name

Union

SELECT Person.ID,Person.Name, Sum(Sales.TotalPrice) AS SumOfTotalPrice
FROM Person INNER JOIN Sales ON Person.ID = Sales.PersonID
WHERE (((Person.ReferralNrID)=TTT))
GROUP BY Person.ID, Person.Name
---

I want to transfer TTT from first sql clause to second.

But this sql query doesn't work correct, TTT appears like parameter in
second query.

Sorry for my EN
--------
Regards,
Tomas

 

Re:sql union


I have solved  this problem by myself. Thanks.

Quote
"Tomas Rutkauskas" <tom...@mail.lt> wrote in message

news:3eb620bd@newsgroups.borland.com...
Quote
> Hello,

> Maybe someone knows how to transfer parameter from one query to other in
> union

> ---
> SELECT Person.ID as TTT,Person.Name, Sum(Sales.TotalPrice) AS
> SumOfTotalPrice
> FROM Person INNER JOIN Sales ON Person.ID = Sales.PersonID
> WHERE (((Person.ID)=19))
> GROUP BY Person.ID,Person.Name

> Union

> SELECT Person.ID,Person.Name, Sum(Sales.TotalPrice) AS SumOfTotalPrice
> FROM Person INNER JOIN Sales ON Person.ID = Sales.PersonID
> WHERE (((Person.ReferralNrID)=TTT))
> GROUP BY Person.ID, Person.Name
> ---

> I want to transfer TTT from first sql clause to second.

> But this sql query doesn't work correct, TTT appears like parameter in
> second query.

> Sorry for my EN
> --------
> Regards,
> Tomas

Other Threads