Help with query

  • I need help with the following query -

     SELECT     site,campus_id, pin

     FROM          dbo.tblStudents

     WHERE      dbo.tblStudents.site

     not in

    ( select site,campus_id, pin

       from  dbo.tblstudents

       where site='M' and career_level='u')

    I need to weed out all undergrads on campus M. Only the undergrads, I still need the Grads on campus M and all other satellite campuses of the university.

    I cant figure this out to save my life! I would greatly appreciate any help!

    Thanks in advance!

    Shree

     

  • SELECT site,campus_id, pin

    FROM dbo.tblStudents

    WHERE

    -- get all students at site M that are not undergrads

    (site = 'M' and career_level 'u')

    OR

    -- an all students at any other site

    (site 'M')

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • Thanks for the reply, I had tried the (site = 'M' and career_level <> 'u') but I get only students on Campus M who are not undergrads with that.

    How do I say, " I need all students from campus M,N,E but only grad students from campus M " ? That is what is getting me!

    Thanks,

    Shree

  • That's what the OR part accomplishes.

    All students not at M regardless of their career_level.

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • aah...as you can see I am really a newbie at writing queries. Thank you so much for your help!

    Shree

Viewing 5 posts - 1 through 4 (of 4 total)

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