Solved

sql select time convert to  time to   a   b mysql

Posted on 2016-11-13
4
146 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 29

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 29

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

630 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