Solved

sql select time convert to  time to   a   b mysql

Posted on 2016-11-13
4
41 Views
Last Modified: 2016-11-13
worktime  
09:01
09.00
09.30
09.35



how can I  select  from 09:00   to   09:29 become a  
and  09:30 to 09:35  become a

result
worktime         timenote
09:01                a
09.00                a
09.30                b
09.35                b

remark worktime colum is timestampFormat

SELECT WORKTIME  ,  fUNCTION( WORKTIME)      ETC
0
Comment
Question by:teera
  • 2
  • 2
4 Comments
 
LVL 24

Expert Comment

by:Pawan Kumar
ID: 41885834
Your question is not very clear ? Can you state your question and the expected output clearly?
0
 

Author Comment

by:teera
ID: 41885860
Table have only one column  but I want out put 2 column

original table

worktime  
09:01
09.00
09.30
09.35

out put table

worktime         timenote
09:01                a
09.00                a
09.30                b
09.35                b
0
 
LVL 24

Accepted Solution

by:
Pawan Kumar earned 500 total points
ID: 41885885
try..

CREATE TABLE `Examplex`
(
 `id`                  INTEGER(10),      
 `created_at`          DATETIME,
  PRIMARY KEY (id)
);


INSERT INTO `Examplex` (`id`,`created_at` ) VALUES (1,'2016-11-14 09:17:47.473')

INSERT INTO `Examplex` (`id`,`created_at` ) VALUES (2,'2016-11-14 09:17:47.473')

INSERT INTO `Examplex` (`id`,`created_at` ) VALUES (3,'2016-11-14 09:30:47.473')

INSERT INTO `Examplex` (`id`,`created_at` ) VALUES (4,'2016-11-14 09:31:47.473')

INSERT INTO `Examplex` (`id`,`created_at` ) VALUES (5,'2016-11-14 09:35:47.473')



SELECT `created_at` as WorkTime , 
	CASE 
		WHEN CAST(`created_at` AS TIME) >= '9:00' AND CAST(`created_at` AS TIME) <= '9:30' THEN 'a'
        ELSE 'b'
    END AS timeNote
FROM `Examplex`

Open in new window

0
 

Author Closing Comment

by:teera
ID: 41885914
Thank you
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Creating and Managing Databases with phpMyAdmin in cPanel.
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now