Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 100

Grouping while combining Date and Hour - response (1) by dnoeth

$
0
0

The easiest way is to group by two columns:
CAST(row_added_ts AS DATE), EXTRACT(HOUR FROM row_added_ts)
 
You can also cast to a string, but your format will not allow correct sorting:
to_char(row_added_ts , 'mm/dd/yyyy HH12 PM')
Internationla standard format sorts ok:
to_char(row_added_ts , 'yyyy-mm-dd HH24')
 
Or you cast to a string & back:
cast(to_char(row_added_ts , 'yyyy-mm-dd HH24') as timestamp(0) format 'yyyy-mm-ddBhh') 

 

Or you subtract minutes & seconds:
row_added_ts
  - (extract(minute from row_added_ts) * interval '1' minute)
  - (extract(second from row_added_ts) * interval '1' second)


Viewing all articles
Browse latest Browse all 100

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>