none
Data retrieve RRS feed

  • Question

  • I have a table, 2 fields EmpId and Gender

    While retrieving data from this table Read 1 as Female, 2 and 3 as Male

    EmpId              Gender

    ---------------------------

    1                        Male

    2                      Female

    3                      Male

    Please help!!!!

    Monday, January 6, 2020 3:41 AM

Answers

  • Hi,

    create table #table1 (EmpId int, Gender varchar(50))
    insert #table1 values (1,'Male'),(2,'Female'),(3,'Male')

    select *, case
              when empid = 1 then 'Female'
              when empid in (2,3) then 'Male'
      end 
    from #table1

    Mark as answer if it workds. Thanks.

    • Marked as answer by Usha1607 Monday, January 6, 2020 7:35 AM
    Monday, January 6, 2020 3:48 AM

All replies

  • Hi,

    create table #table1 (EmpId int, Gender varchar(50))
    insert #table1 values (1,'Male'),(2,'Female'),(3,'Male')

    select *, case
              when empid = 1 then 'Female'
              when empid in (2,3) then 'Male'
      end 
    from #table1

    Mark as answer if it workds. Thanks.

    • Marked as answer by Usha1607 Monday, January 6, 2020 7:35 AM
    Monday, January 6, 2020 3:48 AM
  • Thanks for the help
    Monday, January 6, 2020 7:36 AM