Results 1 to 6 of 6

Thread: Count Data

  1. #1
    Join Date
    Jan 2004
    Location
    ny
    Posts
    16

    Unanswered: Count Data

    Hello,
    Please need your help.

    I need a way to count data from table 1
    where amount of id's with type of 'AP'
    is grater than the number of id's
    in table B where type is = '31'
    ID from Table A is equal to ID in Table B



    Thanks a lot


    Igorema

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >I need a way to count data from table 1
    Good for you!
    What have you tried so far?
    which school, class & instructor assigned you this homework?

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Count Data

    Does this do it?

    select id, count(*)
    from table1
    where type = 'AP'
    group by id
    having count(*) >
    ( select count(*)
    from table2
    where table2.id = table1.id
    and table2.type='31'
    );

  4. #4
    Join Date
    Apr 2003
    Location
    Greenville, SC (USA)
    Posts
    1,155
    Try this:

    select id,count(*) from table1 where type = 'AP' group by id
    having count(*) > (select count(*)
    from table2
    where table2.id = table1.id
    and table2.type='31' )

    HTH
    Gregg

  5. #5
    Join Date
    Jan 2004
    Location
    North Haven, CT
    Posts
    110
    you can try using having clause in group by

  6. #6
    Join Date
    Jan 2004
    Location
    ny
    Posts
    16

    Re: Count Data

    Originally posted by andrewst
    Does this do it?

    select id, count(*)
    from table1
    where type = 'AP'
    group by id
    having count(*) >
    ( select count(*)
    from table2
    where table2.id = table1.id
    and table2.type='31'
    );


    THANK YOU

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •