RE: Subquery?
- From: kohai <kohai@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 16 Jan 2009 07:08:01 -0800
Clifford,
Thanks for this. When I was trying to get to an answer, I think I had
subquery in my head and forgot about the self-join. Much appreciated.
Regards,
k
"Clifford Bass" wrote:
Hi Kohai,.
Try this, which avoids the sub queries and grouping:
select distinct A.*
from (trades as A inner join trades as B on B.tName = A.tName) inner join
trades as C on C.tName = A.tName
where B.tTrans = "buy" and C.tTrans = "sell";
Clifford Bass
"kohai" wrote:
I have a table that has the following fields:
tDate, tName, tTrans, tAmt, tPrc
I am trying to write a query for all tDates where I can get all of the data
for any of the tNames where tTrans has both Buys and Sells. There are a lot
of names that are only on one side or the other, but I can't figure out to
get a query that returns only those that had both types of transactions.
Thanks for your assistance.
Regaards,
Kohai
- Follow-Ups:
- RE: Subquery?
- From: Clifford Bass
- RE: Subquery?
- References:
- Subquery?
- From: kohai
- RE: Subquery?
- From: Clifford Bass
- Subquery?
- Prev by Date: Re: Repeating records in Query
- Next by Date: Re: do a query based on a text box with data or empty text box
- Previous by thread: RE: Subquery?
- Next by thread: RE: Subquery?
- Index(es):
Relevant Pages
|