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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
M

Member 2655861

@Member 2655861
About
Posts
3
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Using the output of a case statement as selection criteria in an IN clause
    M Member 2655861

    Thanks for that. I had come to the same conclusion myself. Seems a pity that CASE could not be used a quirk of SQL Server!!

    Database

  • Using the output of a case statement as selection criteria in an IN clause
    M Member 2655861

    I have tried that but get a syntax error line 14 Incorrect syntax near the keyword 'SELECT' line 15 Incorrect syntax near ')' line 14 ELSE SELECT 'W' UNION SELECT 'R' line 15 END) I have tried just the SELECT CASE part of the Query with no group key and line 14 as ELSE 'W'+','+'R' and this returns W,R. Even tried doubling up the quotes viz: ELSE '''W'''+','+'''R''' which returns 'W','R' but this also fails to bring back rows

    Database

  • Using the output of a case statement as selection criteria in an IN clause
    M Member 2655861

    I have the code below which works fine in the two WHEN parts. However when the two parts fail, because the group key is absent (a valid condition) I want to choose both, hence the ELSE part. But no rows are returned in this case. mantype can be W or R SELECT * FROM callsigns WHERE mantype IN (SELECT CASE WHEN EXISTS(SELECT 1 FROM group gr1 WHERE gr1.group_key = 'RA' AND gr1.gra_valid = 1 AND 0 = (gr1.gra_flags & 7)^3) THEN 'R' WHEN EXISTS(SELECT 1 FROM group gr2 WHERE gr2.group_key = 'RA' AND gr2.gra_valid = 1 AND 0 = (gr2.gra_flags & 7)^1) THEN 'W' ELSE 'W'+','+'R' END)

    Database
  • Login

  • Don't have an account? Register

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