Redshift order by DESC is not working

0

hello, i've a very simple query of the pattern SELECT timestamp_column FROM a_table WHERE columnID = 'column_value' ORDER BY timestamp_column DESC the result set does not come back in descending order i've rewritten this in many ways. any ideas? thanks!

질문됨 일 년 전236회 조회
1개 답변
1

I tested below and I see that ordering is properly applied highest to lowest. Can you check if timestamp_column is defined as timestamp not string?

create table test_ts_order
(timestamp_column  timestamp);

insert into test_ts_order 
select getdate()
--wait few seconds
insert into test_ts_order 
select getdate()
--wait few seconds
insert into test_ts_order 
select getdate()
select * from test_ts_order order by timestamp_column desc;

  • 2022-11-11 21:47:09
  • 2022-11-11 21:46:47
  • 2022-11-11 21:46:22
select version()

PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.43331

AWS
Bhanu_P
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인