我已手动编码以显示船舶“会计周号”并分为月份
select `Ship Fiscal Week Number`,
CASE
WHEN Ship Fiscal Week Number` <=5 THEN "January"
WHEN Ship Fiscal Week Number`<= 9 THEN "Feburary"
WHEN Ship Fiscal Week Number` <=13 THEN "March"
WHEN Ship Fiscal Week Number`<= 18 THEN "April"
WHEN Ship Fiscal Week Number`<= 22 THEN "May"
WHEN Ship Fiscal Week Number`<= 26 THEN "June"
WHEN Ship Fiscal Week Number`<= 31 THEN "July"
WHEN Ship Fiscal Week Number`<= 35 THEN "August"
WHEN Ship Fiscal Week Number`<= 39 THEN "September"
WHEN Ship Fiscal Week Number`<= 44 THEN "October"
WHEN Ship Fiscal Week Number`<= 48 THEN "November"
WHEN Ship Fiscal Week Number`<= 52 THEN "December"
else "Nothing"
END AS `Ship Fiscal Period Number`
然后我想将其与其他显示如下数据的表连接起来:
select Product,
Ship Fiscal Week Number,
Ship Fiscal Year Number,
Order Group,
Amount,
Invoices,
Order_Quantity
from table 2
那么我该如何显示这样的o / p?
Product A| January| Eyemakeup
我要显示的不是船舶财务周编号,而是要显示船舶财务周编号属于哪个月份。
谢谢。
答案 0 :(得分:0)
我不确定您的数据是什么样,什么列等于“ Eyemakeup”,但是如果第二个查询中列出的列在一个表中可用,则可以执行以下操作:
select Product,
CASE
WHEN Ship Fiscal Week Number` <=5 THEN "January"
WHEN Ship Fiscal Week Number`<= 9 THEN "Feburary"
WHEN Ship Fiscal Week Number` <=13 THEN "March"
WHEN Ship Fiscal Week Number`<= 18 THEN "April"
WHEN Ship Fiscal Week Number`<= 22 THEN "May"
WHEN Ship Fiscal Week Number`<= 26 THEN "June"
WHEN Ship Fiscal Week Number`<= 31 THEN "July"
WHEN Ship Fiscal Week Number`<= 35 THEN "August"
WHEN Ship Fiscal Week Number`<= 39 THEN "September"
WHEN Ship Fiscal Week Number`<= 44 THEN "October"
WHEN Ship Fiscal Week Number`<= 48 THEN "November"
WHEN Ship Fiscal Week Number`<= 52 THEN "December"
else "Nothing"
END AS `Ship Fiscal Month`
from table 2