Assuming that all records in tableabjoin have parents in table A. you should be able to do this with select count(distinct(t.use_no, t.year)) as tableAsum from tableabjoin t group by t.error_code
note: Select is pseudo code since I don't which database you're using. Syntax is not exact. On Thu, Feb 5, 2009 at 7:37 AM, Ian Skinner <[email protected]> wrote: > > Can I do this in one query... or am I going to have to do some looping > and counting? > > I have two tables joined in a many to many relation. I would like to > count how many records in table A are joined to table B and how many > joins between table A and table B. In other words, how many records in > table A have one or more errors and how many errors are there, grouped > by error code. > > Table A > use_no > year > > Table B > error_code > > TableABjoin > use_no > year > error_code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/sql/message.cfm/messageid:3187 Subscription: http://www.houseoffusion.com/groups/sql/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.6
