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

  • SEARCH
  • Home
  • 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 7005617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:22:25+00:00 2026-05-27T21:22:25+00:00

I have this table where columns correspond to names: i.e. 11 = first, 12

  • 0

I have this table where columns correspond to names:

i.e. 11 = first, 12 = second, 13 = third..

COLUMNID(string)  starttime(string) endtime(string) 

11                 20111203123132    20101203143239
11                 20101203143156     20101203143322
11                     ...               ...
12
12
13
14
16
17
18
18

I would need a query to give me names instead of ID

COLUMNAME(string)  starttime(string) endtime(string) 
FIRST                 20111203123132    20101203143239
FIRST                 20101203143156     20101203143322
FIRST                    ...               ...
FIRST
FIRST
SECOND
SECOND
THIRD
...

SOLUTION:

SELECT ID, USERID, ( CASE
WHEN SUBSTR(USERID,1,4) LIKE ‘CC0%’ THEN ‘ADMIN’
WHEN SUBSTR(USERID,1,4) LIKE ‘CC1%’ THEN ‘THEO’
WHEN SUBSTR(USERID,1,4) LIKE ‘CC12%’ THEN ‘PAT’
WHEN SUBSTR(USERID,1,4) LIKE ‘CC13%’ THEN ‘DOUG’
WHEN SUBSTR(USERID,1,4) LIKE ‘C22%’ THEN ‘PHIL’
WHEN SUBSTR(USERID,1,4) LIKE ‘K15%’ THEN ‘SONIA’
WHEN SUBSTR(USERID,1,4) LIKE ‘k16%’ THEN ‘JEAN’
WHEN SUBSTR(USERID,1,4) LIKE ‘P58%’ THEN ‘FAB’
WHEN SUBSTR(USERID,1,4) LIKE ‘P9%’ THEN ‘LOG’
ELSE ‘N/A’
END ) USERNAME
FROM LOG_HISTORY

  • 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-27T21:22:26+00:00Added an answer on May 27, 2026 at 9:22 pm

    This depends on what database type you are targetting. If you are targeting SQL Server, I would suggest exploring something like this

    SELECT Name = 
       CASE COLUMNID
          WHEN '11' THEN First 
          WHEN '12' THEN Second
       END,
       starttime, endtime
    FROM yourtable
    

    You may want to look at your database design. I’m not sure what you curently have is the best to achieve the result you seem to want. Is there a reason starttime and endtime columns are strings instead of datetime?

    Edit : Modified Query to match question update

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

Sidebar

Related Questions

i have this three tables. Table: Item Columns: ItemID, Title, Content, NoChange (Date) Table:
I have a table TreeStructures wich holds structures of Trees. This table has columns
Let's say I have a table Foo . This table has the columns ID
I have a table of product information with many bit columns. This table can
I have a table structure with columns like this [ID] [Name] [ParentId] [ParentName] The
I have a table with arbitrary columns and rows. This fact is irrelevant though
I have a multi-table query, similar to this (simplified version) SELECT columns, count(table2.rev_id) As
I have this XML in a column in my table: <keywords> <keyword name=First Name
So basically I have been trying to insert columns into my third table from
I have a query like this: SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE FROM MY_DB.INFORMATION_SCHEMA.COLUMNS WHERE

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.