Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Query

SQL Query

Scheduled Pinned Locked Moved Database
databasetutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dabuskol
    wrote on last edited by
    #1

    Most of the time there are two/three record in the table. How can you do it in SQL IF Status = 1 or status = 0 THEN Desc = "In Progress" TabID Status T1 1 T1 0 If Status = 1 or status = 1 THEN Desc = "Ok" TabID Status T1 1 T1 1 If status = 0 or status = 0 THEN Desc = "failed" TabID Status T1 0 T1 0 Select should give me 1 row only My example is not correct, kindly enhance.

    select tabid, GroupDesc = case when groupstatus = '1' or groupstatus = '0' then 'In Progress'
    else 'Ok' end
    from tab1
    where tabid = T1

    Dabsukol

    M 1 Reply Last reply
    0
    • D dabuskol

      Most of the time there are two/three record in the table. How can you do it in SQL IF Status = 1 or status = 0 THEN Desc = "In Progress" TabID Status T1 1 T1 0 If Status = 1 or status = 1 THEN Desc = "Ok" TabID Status T1 1 T1 1 If status = 0 or status = 0 THEN Desc = "failed" TabID Status T1 0 T1 0 Select should give me 1 row only My example is not correct, kindly enhance.

      select tabid, GroupDesc = case when groupstatus = '1' or groupstatus = '0' then 'In Progress'
      else 'Ok' end
      from tab1
      where tabid = T1

      Dabsukol

      M Offline
      M Offline
      Michael J Eber
      wrote on last edited by
      #2

      Try this:

      SELECT tableIdentity,
      case when groupstatus = 1 or groupstatus = 0 then 'In Progress' else 'OK' end GroupDesc
      from tableOne
      where tabid = T1;

      You should also physically confirm that you have only a single row named T1.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups