in Education by
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 JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
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

Related questions

0 votes
    How to set same number 'priority' with one query for Mercedes. +--------------------- ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    In Hive, when we do a query (like: select * from employee), we do not get any column names in the ... when you execute any query? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    How can a column with a default value be added to an existing table in SQL Server 2000 / SQL Server 2005? Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I would like to take a list of names (e.g. john, mary, paul) and create a SQLite "select" ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    FQL statement has executed and array object has been passed to $fqlResult successfully. However, I'm unable ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    The structure of a table Employee is given below. Suggest suitable data type and size of each column. Column name ... _ Design _ _ Select the correct answer from above options...
asked Dec 11, 2021 in Education by JackTerrance
0 votes
    SQL structure such as table names, column names, and so on cannot be escaped, and thus user-supplied structure names are ... issue in a report-writing software. 1. True 2. False...
asked Mar 20, 2021 in Technology by JackTerrance
0 votes
    The SQL query to create a new database COMPANY * a) SELECT DATABASE COMPANY; b) CREATE DATABASE COMPANY; c) ... All of the above Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    I need to take the users input from the select box for Allergen1 once an option is selected and the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I have an application that uses FCM to receive messages from a custom server. There are some situations ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I have the following data frame, I want to find the name of the column with the minimum date for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I have a list of files in a folder in my system file_list= ["A", "B", "C"] I Have read the files using ... C How do I accomplish this? Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    An inverse network may be obtained by converting each resistance element R into a corresponding resistive element of ... EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 12, 2021 in Education by JackTerrance
0 votes
    Using the WCF web programming model one can specify an operation contract like so: [OperationContract] [WebGet ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    In a project we are using CodeSmith to generate database layer, Codesmith seperate creates service classes for ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
...