Results 1 to 2 of 2

Thread: Help SQL query

  1. #1
    Join Date
    Dec 2003
    Posts
    14

    Unanswered: Help SQL query

    Guys pls help me in writing this query using CASE's .

    emp_id status date
    1 A 2000-01-01
    2 A 2001-01-01
    3 A 2002-01-01
    4 A 1999-01-01
    5 A 1998-01-01
    6 I 2004-01-01
    7 T 1995-01-01

    If Status is NOT equal 'A' select the emp_id
    If Status is equal 'A' select the emp_id only when DT>='2000-01-01'

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    case when status = 'A' then case when dt >= '2000-01-01' then emp_id else null end else emp_id end

    Andy

Posting Permissions

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