If you're willing to get a component to do the job you can look at TXQuery.
http://www.sigmap.com/txquery.htm

It allows you to create queries on any TDataset, and you can even do
crosstab queries like MS Access.

Cheers,
Scott.

-----Original Message-----
From: Peter Vroegop [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 1 February 2001 13:34
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Newbie SQL question


Yes, thanks Stacey,
I've been trying to go down the Temporary table road, but not with a lot of
success.

My SQL statement looks like this:

Insert into Copytemp
(Rep, Name,InvDate,invno,Total,GST,TotExtend,TotCost)
Select  I.Rep,I.Name, I."date",I.Invno, I.Total,I.GST,SUM(O.extend) As
TOTExtend,SUM(O.cost) AS TOTCost  
from invidx I, OldInv O
Where
(I.link = o.invno and I.Rep =  '10' and I."date" > '12/01/2000' and I."date"
< '12/31/2000')
Group by I.Rep,I.Name,I."date",I.Invno,I.Total,I.GST

As long as I don't have the "SUM" expressions in there, things work OK, but
the moment I put them in, it refuses to cooperate. 

Peter Vroegop

At 11:47 01/02/2001 +1300, you wrote:
>I'm not too sure about Locak SQL, but you usually do nested queries using
>in, or exists.
>
>eg. 
>
>select name from people
>where company in (select company from companies where city = 'Auckland')
>
>
>Another option is to create a temporary table, and then join to it.
>
>eg.
>
>Create your temporary table.
>
>insert into company_temp
>select company from companies
>where city = 'Auckland'
>
>select name from people, company_temp
>where people.name = company_temp.name
>
>Stacey
>
>> -----Original Message-----
>> From: Peter Vroegop [mailto:[EMAIL PROTECTED]]
>> Sent: Thursday, 1 February 2001 11:21 a.m.
>> To: Multiple recipients of list delphi
>> Subject: [DUG]: Newbie SQL question
>> 
>> 
>> Is it possible to do a query on the result set of a previous 
>> query. If so, how do you go about it?
>> 
>> (Using D3 and Local SQL)
>> 
>> Peter Vroegop
>> 
>> --------------------------------------------------------------
>> -------------
>>     New Zealand Delphi Users group - Delphi List - 
>> [EMAIL PROTECTED]
>>                   Website: http://www.delphi.org.nz
>> To UnSub, send email to: [EMAIL PROTECTED] 
>> with body of "unsubscribe delphi"
>> 
>---------------------------------------------------------------------------
>    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                  Website: http://www.delphi.org.nz
>To UnSub, send email to: [EMAIL PROTECTED] 
>with body of "unsubscribe delphi"

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to