Re: How can I improve this query?

2009-12-02 Thread Tom Worster
On 12/2/09 11:13 AM, "David Shere" wrote: > Tom Worster wrote: >> how about using LEFT JOIN: >> >> SELECT ... >> FROM listings a >> LEFT JOIN Transactions b ON b.PartNumber = a.PartNumber > > This gives me a result set of 456,567 lines. I'm looking for a result > set of 60-70 lines. (That's h

Re: How can I improve this query?

2009-12-02 Thread mos
At 10:13 AM 12/2/2009, you wrote: Tom Worster wrote: > how about using LEFT JOIN: > > SELECT ... > FROM listings a > LEFT JOIN Transactions b ON b.PartNumber = a.PartNumber This gives me a result set of 456,567 lines. I'm looking for a result set of 60-70 lines. (That's how many part numbers w

Re: How can I improve this query?

2009-12-02 Thread David Shere
Tom Worster wrote: > how about using LEFT JOIN: > > SELECT ... > FROM listings a > LEFT JOIN Transactions b ON b.PartNumber = a.PartNumber This gives me a result set of 456,567 lines. I'm looking for a result set of 60-70 lines. (That's how many part numbers we have.) > and for speed, does Tra

Re: How can I improve this query?

2009-12-01 Thread mos
At 01:21 PM 12/1/2009, David Shere wrote: select distinct a.PartNumber as 'Part Number', ( select count(1) from Transactions b where b.PartNumber = a.PartNumber) as 'No. Sold' from listings a order by a.PartNumber It currently takes 30 seconds to run. Transactions has 1200 records and

Re: How can I improve this query?

2009-12-01 Thread Tom Worster
On 12/1/09 2:21 PM, "David Shere" wrote: > select distinct a.PartNumber as 'Part Number', ( > select count(1) > from Transactions b > where b.PartNumber = a.PartNumber) as 'No. Sold' > from listings a > order by a.PartNumber > > It currently takes 30 seconds to run. Transactions has

How can I improve this query?

2009-12-01 Thread David Shere
select distinct a.PartNumber as 'Part Number', ( select count(1) from Transactions b where b.PartNumber = a.PartNumber) as 'No. Sold' from listings a order by a.PartNumber It currently takes 30 seconds to run. Transactions has 1200 records and listings has 7000. Multiple listings can