Postgres:根据 Ralph Kimball 创建日期维度
我是 postgres 和 DW 的新手,我必须设计 书。我在网上看到了很多地方,到目前为止我还没有成功,可以解释一下如何填充诸如“财政周”,“财政月”,“财政半年”之类的字段
谢谢
I am new to postgres and DW, and I have to design a DATE Dimension
as given in book. I saw many places on the web and I did not succeed so far, can some explain how to populate fields like 'Fiscal Week', 'Fiscal Month', 'Fiscal Half year'
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜您需要 10 年日期维度表,其中包含图 2.4 中显示的所有列(基于 Google 图书)。查看文档:
to_char
与 表 9-21对于模板模式date_part
generate_series(start, stop, stepinterval)
要获取 10 年内的所有日期,您可以编写:
根据图 2.5 创建表,例如:
插入命令:
I希望这能为您提供一些框架和起点。
I guess that you want 10 years Date Dimension table with all columns presented in Figure 2.4 (based on Google Books). Check in documentation:
to_char
with Table 9-21 for template patternsdate_part
generate_series(start, stop, step interval)
To get all days within 10 years you could write:
According to Figure 2.5 create table as e.g.:
Insert command:
I hope this gives you some framework and starting point.
您的财政年度是如何构成的?什么时候开始?它是否遵循任何标准 4-4-5 或 4-5-4 规则?您最好的选择可能是从 CSV 文件加载它,如此问题的答案中所述:4-5-4 国家零售基金会日历 csv 下载或创建函数。众所周知,财政年度是不标准的。例如,我们公司的会计年度从 7 月 1 日开始。
我必须向广播日历的日历维度添加字段(从包括 1 月 1 日在内的一周的星期一开始),并且能够通过一些计算来完成此操作。
How is your fiscal year structured? When does it start? Does it follow any standard 4-4-5 or 4-5-4 rules? Your best bet might be loading it from a CSV file such as discussed in the answer to this question: 4-5-4 National Retail foundation Calendar csv download or function to create. Fiscal years are notoriously non-standard. For example, the fiscal year of our company starts July 1st.
I had to add fields to our calendar dimension for the broadcast calendar (starts on the Monday of the week that includes January 1st) and was able to do it with some calculations.