Solved

sql select time convert to  time to   a   b mysql

Posted on 2016-11-13
4
99 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 28

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 28

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
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.

730 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