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

Thread: problem in select query

Threaded View

  1. #9
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    Thanks akkerend. You did excellent job.

    Slimdave, You missed some thing.

    10:39:15 SQL> L
    1 select student_id
    2 from my_table
    3 where course in ('java','c')
    4 group by student_id
    5* having count(distinct course) = 2
    10:39:18 SQL> /

    STUDENT_ID
    ----------
    13
    15

    Once again Big Thanks to akkerend.

    PHP Code:
    Another method:

    select student_id
    from
    (
    select student_id ,
           
    sum(case
            
    when course 'c' then 1
             
    else 0
           end
    c_count,
           
    sum(case
            
    when course 'java' then 1
             
    else 0
           end
    java_count,
           
    sum(case
            
    when course <> 'java' and course <> 'c' then 1
             
    else 0
           end
    oth_count
    from my_table
    group by student_id
    )
    where c_count =and java_count=and oth_count 0
    /

    Tamil
    Last edited by tamilselvan; 08-25-2004 at 01:45 PM.

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