using count using data from 2 tables?

  • I've got 2 tables and would like to do a Count on 1 table whilst checking against a second table, is this possible?

    table1                                                   table2

    [name]        [age]       [Location]               [name]        [job]         

    fred               20         London                   george         driver

    george           20         London                   tony            plumber

    tony              20         paris                      alice            driver

    jim                21         Milan                      fred             plumber

     

    the sort of query I need is

    count  from table1 where names are also in table2 that are drivers

    any ideas?

  • select count(*) from

    table1 inner join table2

    on table1.name = table2.name

    where table2.job = 'driver'

    Russel Loski, MCSE Business Intelligence, Data Platform

  • many thanks Russel

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply