簡體   English   中英

為什么 Big Query 中的 order by 不起作用?

[英]Why does the order by in Big Query not working?

我正在嘗試在大查詢中使用 order by 對我的查詢進行排序。 我想做的是,根據一年中的周數對結果進行排序,但它似乎不起作用。 它也沒有顯示任何類型的語法問題。

SELECT  *  FROM (SELECT concat(cast(EXTRACT(week FROM elt.event_datetime) as string),', ', extract(year from elt.event_datetime)) WEEK,  elt.msg_source SOURCE, (elt.source_timedelta_s_ + elt.pipeline_timedelta_s_) Latency  FROM    <table> elt join ,<table1> ai ON elt.msg_id = ai.msg_id  WHERE ai.report_type <> 'PFR' and   EXTRACT(date    FROM      elt.event_datetime) > extract(date from (date_sub(current_timestamp(), INTERVAL 30 day)))
order by WEEK desc)PIVOT ( AVG(Latency) FOR SOURCE IN ('FLYHT',      'SMTP')) t 

基本上,我想要我的結果,因為它們在下圖中以綠色編號。

在此處輸入圖像描述

有人可以檢查是什么問題嗎?

SELECT  *  FROM (SELECT concat(cast(EXTRACT(week FROM elt.event_datetime) as string),', ', extract(year from elt.event_datetime)) WEEK,  elt.msg_source SOURCE, (elt.source_timedelta_s_ + elt.pipeline_timedelta_s_) Latency  FROM    <table> elt join ,<table1> ai ON elt.msg_id = ai.msg_id  WHERE ai.report_type <> 'PFR' and   EXTRACT(date    FROM      elt.event_datetime) > extract(date from (date_sub(current_timestamp(), INTERVAL 30 day))))
PIVOT ( AVG(Latency) FOR SOURCE IN ('FLYHT',      'SMTP')) t order by (select RIGHT(t.WEEK,4)) desc ,(select regexp_substr(t.WEEK,'[^,]+')) desc

正如@Shipra Sarkar 在評論中所建議的那樣。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM