Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select count

Status
Not open for further replies.

kristinac

Programmer
Jul 18, 2003
98
US
I would like to get the count of the number of records returned by the following stmt:

SELECT DISTINCT ...<a bunch of fields from all tables>
FROM Streets INNER JOIN (Addresses LEFT JOIN (Segments LEFT JOIN ESNs ON Segments.ESNId = ESNs.Id) ON (Addresses.StreetId = Segments.StreetId) AND (Addresses.Address > Segments.BAddress) AND (Addresses.Address < Segments.EAddress)) ON Streets.Id = Addresses.StreetId

That stmt does work properly. This one doesn't - I tried doing a count this way:

SELECT COUNT(*) FROM Streets INNER JOIN (Addresses LEFT JOIN (Segments LEFT JOIN ESNs ON Segments.ESNId = ESNs.Id) ON (Addresses.StreetId = Segments.StreetId) AND (Addresses.Address > Segments.BAddress) AND (Addresses.Address < Segments.EAddress))ON Streets.Id = Addresses.StreetId

However I get more records from this stmt than the first one. Is there a way to use the first statement's setup to get a count?

Any advice would be appreciated.
 
Thanks. I actually have to use vb to write the queries, but the answer was basically the same. I can't believe I didn't think of that!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top