sql count (revised) sorry

  • sorry i got one to work but have another problem with a 2nd query

    table 1

    jobid  jobname               state

    ______________________________

    1      accountant            ga

    2      sales                     fl

    3      clerk                     ga

    4      repairman               tn

    table 2

    statename             stateabbrv

    ______________________________

    Texas                        tx

    Alabama                     al

    Georgia                      ga

    Florida                        fl

    Tennesse                    tn

    databind a dropdownlist

    Alabama(0)

    Florida(1)

    Georgia(2)

    Tennesse(1)

    Texas(0)

    thanks again for all the help!

    I'm guessing you can't really count state in table1 when nothing is there.

  • select t2.statename, count(*) as jobnames

    from table2 as t2

    left join table1 as t1 on t1.state = t2.stateabbrv

    group by t2.statename

     


    N 56°04'39.16"
    E 12°55'05.25"

  • this is almost perfect except for the states that have no jobs has a count of 1 instead of 0.

    got it to work.. change the count(t1.state) thanks

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

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