Query the non-partitioned table, you could first convert to character, and use the desired format. After that you can convert to date:
select * from myuser.mytable where to_date(to_char(created_date,'YYYY.MM.DD'),'YYYY.MM.DD') between '2020.01.01' and '2020.01.31';
To query the partitioned table, you need an an explicit cast to the same data type used by the partitioned key column:
select * from myuser.mytable where cast(created_date as date) between '2020.01.01' and '2020.01.31';I realized this difference when the number of rows returned was not what I expected. After I changed my SQL statement to use CAST, the number of rows was exactly what I expected.
No comments:
Post a Comment