Solved

sql select time convert to  time to   a   b mysql

Posted on 2016-11-13
4
21 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 17

Expert Comment

by:Pawan Kumar Khowal
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 17

Accepted Solution

by:
Pawan Kumar Khowal 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

708 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

12 Experts available now in Live!

Get 1:1 Help Now