I would like to a SQL code to update the column area
based on a interval of time daily.
also my start_time
column is varchar2
, not date
column
eg:
between 06:00:00 and 10:00:00 = 'A'<br>
between 10:00:00 and 15:30:00 = 'B'<br>
between 15:30:00 and 22:00:00 = 'C'<br>
table name: myTable
id name start_time area
============================================
1 a 06/07/19 11:00 -
2 b 06/07/19 09:00 -
3 c 06/07/19 11:00 -
4 d 07/07/19 13:00 -
5 e 07/07/19 21:00 -
6 f 08/07/19 16:00 -
7 g 08/07/19 01:00 -
8 h 08/07/19 18:00 -
Result:
id name start_Time area
============================================
1 a 06/07/19 11:00 B
2 b 06/07/19 09:00 A
3 c 06/07/19 11:00 B
4 d 07/07/19 13:00 B
5 e 07/07/19 21:00 C
6 f 08/07/19 16:00 C
7 g 08/07/19 01:00 -
8 h 08/07/19 18:00 C
I did a SQL query that works:
select *
from myTable
where TO_CHAR(TO_DATE(TIME_START,'YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS')
BETWEEN TO_CHAR(TO_DATE('2019/11/11/ 06:00:00','YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS')
AND TO_CHAR(TO_DATE('2019/11/11/ 13:30:00','YYYY-MM-DD HH24:MI:SS'), 'HH24:MI:SS')
But I have created a column and now I would like to update it on the records rather than a query.