DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: quary help

  1. #1
    Join Date
    Apr 2001
    Posts
    103

    quary help

    Hello Gurus
    My test_1 has following rows

    AA BB_START BB_END
    AA 1/1/2009 1/1/2009
    BB 1/2/2009 1/2/2009
    AA 1/3/2009 1/3/2009
    XX 1/3/2009 1/3/2009
    YY 1/3/2009 1/3/2009

    and my test_2 has following rows

    select * from test_2

    AA BB_CREATED
    AA 1/3/2009
    BB 1/2/2009
    BB 1/3/2009

    when I do the following query

    select count(tt.aa), tt.aa from test_1 tt, test_2 tp
    where tp.BB_CREATED between tt.BB_START and tt.BB_END
    and tt.aa != tp.aa
    group by tt.aa

    I am getting

    COUNT(TT.AA) AA
    1 AA
    2 XX
    2 YY

    where as I should get

    COUNT(TT.AA) AA
    1 AA
    1 XX
    1 YY

    Can some one help me to get the correct result please
    Thanks for your help
    Naeem

  2. #2
    Join Date
    Apr 2006
    Posts
    377
    Maybe I'm missing something, but the first result seems correct ?? What is it that you are looking to achieve with the query ? Why are you expecting the second result ?

Posting Permissions

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


Click Here to Expand Forum to Full Width