Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7041483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:03:05+00:00 2026-05-28T02:03:05+00:00

I have the following query: Select Name, case when charindex(‘I’,a.S_Data) > 0 then 1

  • 0

I have the following query:

Select Name,
       case when charindex('I',a.S_Data) > 0 then 1 else 0 end as Illustrated,
       case when charindex('FP',a.S_Data) > 0 then 1 else 0 end as FrontPage,
       case when charindex('BP',a.S_Data) > 0 then 1 else 0 end as BackPage,
       case when charindex('ELP',a.S_Data) > 0 then 1 else 0 end as EDLP,
       case when charindex('PR',a.S_Data) > 0 then 1 else 0 end as SpecialPromo
From Table1

What I would like to do is to store those filter values in some sort of lookup table or a settings table.

I am struggling with how to draw the values from a lookup table to use with this query.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:03:06+00:00Added an answer on May 28, 2026 at 2:03 am

    I can think of at least two options…

    CREATE TABLE constants (
      id               AS INT,
      Illustrated      AS VARCHAR(3),
      FrontPage        AS VARCHAR(3),
      BackPage         AS VARCHAR(3),
      EDLP             AS VARCHAR(3),
      SpecialPromo     AS VARCHAR(3)
    )
    
    INSERT INTO constants SELECT 1, 'I', 'FP', 'BP', 'ELP', 'PR'
    
    SELECT
      Name,
      CASE WHEN CHARINDEX(constants.Illustrated, data.S_Data) > 0 THEN 1 ELSE 0 END   AS Illustrated,
      etc, etc
    FROM
      data
    INNER JOIN
      constants
        ON constants.id = 1
    

    Or…

    CREATE TABLE constants (
      constant_set_id  AS INT,
      constant_name    AS VARCHAR(16),
      value            AS AS VARCHAR(3)
    )
    
    INSERT INTO constants SELECT 1, 'Illustrated',  'I'
    INSERT INTO constants SELECT 1, 'FrontPage',    'FP'
    INSERT INTO constants SELECT 1, 'BackPage',     'BP'
    INSERT INTO constants SELECT 1, 'EDLP',         'ELP'
    INSERT INTO constants SELECT 1, 'SpecialPromo', 'PR'
    
    SELECT
      Name,
      MAX(CASE WHEN constants.constant_name = 'Illustrated' AND CHARINDEX(constants.value, data.S_Data) > 0 THEN 1 ELSE 0 END)   AS Illustrated,
      etc, etc
    FROM
      data
    INNER JOIN
      constants
        ON constants.constant_set_id = 1
    GROUP BY
      data.name
    

    Both let you have multiple different sets of constants. One is expandable without changing the schema, though the query still would need to change.

    The main advantage of either approach is that you can re-use the constants else where, but store them once in a centralised location. Which is only relevant if/when the values in the constants needs updating. Re-use through indirection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query: SELECT X.ID, X.NAME, CASE R.ID WHEN NOT NULL THEN
I have the following SQL query: SELECT COUNT(CASE WHEN u.account_new = 1 THEN u.user_id
I have the following query SELECT s.name, s.surname, s.id_nr, s.student_nr, s.createdate, s.enddate, (SELECT count(*)
I have a following SQL QUERY: SELECT articles.name, articles.price, users.zipcode FROM articles INNER JOIN
I have the following query: SELECT DISTINCT w.name, count(*) FROM widgets AS w JOIN
I have the following query: SELECT o.id,o.name FROM object o WHERE ( o.description LIKE
I have problem with following query: SELECT g_contac.contid, g_contac.name, g_contac.email, f_sync.foreign_key, ( SELECT COUNT(g_cpers.cpersid)
I have the following query: SELECT s.id, s.name, s.prom, s.some_other_field, ... many more fields
I have the following query: select column_name, count(column_name) from table group by column_name having
I have a following oracle query: SELECT a.USER_ID, c.first_name, c.last_name, TO_CHAR( b.logon_date, 'MM/DD/YYYY HH:MI:SS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.