Case in Select Statement

0 votes

I have an SQL statement that has a CASE from SELECT and I just can't get it right. 

     Select xxx, yyy
     case : desc case when bbb then 'blackberry';
     when sss then 'samsung';
     end 
     from (select ???? .....

where the results show

 name                         age       handphone
xxx1                         yyy1      blackberry
xxx2                         yyy2      blackberry
Jun 6, 2022 in Ask us Anything! by polo
• 1,480 points
386 views

1 answer to this question.

0 votes

 use:

SELECT CASE
         WHEN upper(t.name) like 'P%' THEN
          'productive'
         WHEN upper(t.name) like 'T%' THEN
          'test'
         WHEN upper(t.name) like 'D%' THEN
          'development'
         ELSE
          'unknown'
       END as type
FROM table t
answered Jun 6, 2022 by nisha
• 2,210 points

Related Questions In Ask us Anything!

+1 vote
0 answers
0 votes
0 answers

all values of R in science

Jul 17, 2019 in Ask us Anything! by anonymous
• 120 points
715 views
0 votes
1 answer

Did anyone received the Data Science Hackathon dataset and problem statement

The problem statement and the data set ...READ MORE

answered Jul 24, 2019 in Ask us Anything! by Edureka
• 2,960 points
1,348 views
–1 vote
0 answers

i want lag in gmail

Jan 7, 2020 in Ask us Anything! by sarah
• 110 points
860 views
0 votes
1 answer
0 votes
2 answers

Case in Select Statement

I think these could be helpful for ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,060 points
478 views
0 votes
1 answer

How do I perform an IF THEN statement in an SQL SELECT?

The CASE statement is the closest to IF in ...READ MORE

answered Feb 16, 2022 in Database by Vaani
• 7,060 points
1,367 views
0 votes
0 answers

"CASE" statement within "WHERE" clause in SQL Server 2008

The query I'm working with has a ...READ MORE

Sep 3, 2022 in Database by Kithuzzz
• 38,010 points
522 views
0 votes
1 answer

Calculate Time Intersection to Correlate Sequences of Independent Events

I think this solution requires a CROSS JOIN implementation. ...READ MORE

answered Oct 26, 2018 in Power BI by Upasana
• 8,620 points
626 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP