I'm trying to select only specific hours from my table that contain "Datetime" and other variables.
Example 1 :
select distinct(Datetime) from NWP_OUT where HOUR(Datetime) = '00';
this works but when i try to select not only '00' no luck and no result
Example 2:
select distinct(Datetime) from NWP_OUT where HOUR(Datetime) = '00' and '06';
only show the first
I tried using 'between' but then i got 02,04,and 05
My end goal is to select only the data for hours: '00,03,06,09,12,18,21' it is 10 years of data so manual selection will be hard.
Thank you all in advance!
Use IN
:
SELECT DISTINCT(datetime)
FROM NWP_OUT
WHERE HOUR(datetime) IN (0, 3, 6, 9, 12, 18, 21)
You want to use IN
SELECT
DISTINCT(Datetime)
FROM
NWP_OUT
WHERE
HOUR(Datetime) IN ('00','03','06','09','12','18','21')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.