我怀疑Redshift不支持命名窗口,因为Postgres至少有8.4版:
select stuff
, stuff_category
, sum(dollars) over W
from table
window W as (partition by stuff_category)
Run Code Online (Sandbox Code Playgroud)
但是我想明确地知道,我找不到任何参考,或者任何帖子上写着"我们并没有因为非常好的理由而实施这个yada yada".
AWS Redshift SQL Reference没有提到'window as'语法 - 我想我应该把它作为答案.
我想看到 Julia 的代码片段,它将读取文件并返回与正则表达式匹配的行(字符串类型)。
我欢迎多种技术,但输出应相当于以下内容:
$> grep -E ^AB[AJ].*TO' 'webster-unabridged-dictionary-1913.txt'
ABACTOR
ABATOR
ABATTOIR
ABJURATORY
Run Code Online (Sandbox Code Playgroud)
我在这里使用 GNU grep 3.1,文件中每个条目的第一行都是大写单词。
Redshift DISTINCT
在其窗口函数中不支持聚合.用于COUNT
声明此状态的AWS文档,并且distinct
不支持任何窗口函数.
我希望本年度的月度和年初至今独特的客户数量,并且还按交通渠道和所有渠道的总数进行划分.由于客户可以多次访问我只需要计算不同的客户,因此Redshift窗口聚合将无济于事.
count(distinct customer_id)...group by
,但这只会给我四个所需的结果.union all
.我希望这不是唯一的解决方案.这就是我在postgres(或Oracle)中写的内容:
select order_month
, traffic_channel
, count(distinct customer_id) over(partition by order_month, traffic_channel) as customers_by_channel_and_month
, count(distinct customer_id) over(partition by traffic_channel) as ytd_customers_by_channel
, count(distinct customer_id) over(partition by order_month) as monthly_customers_all_channels
, count(distinct customer_id) over() as ytd_total_customers
from orders_traffic_channels
/* otc is a table of dated transactions of customers, channels, and month of order */
where to_char(order_month, …
Run Code Online (Sandbox Code Playgroud) 我可以将变量插入字符串中,以使用其他文本打印该值,如下所示:
a = "sheriff";
println("Howdy, I'm the $a.")
Howdy, I'm the sheriff.
Run Code Online (Sandbox Code Playgroud)
我需要插入数组元素的语法,我目前得到的是:
A = ["carb", "sheriff", "mumchance"]
println("Howdy, I'm the $A[2].")
Howdy, I'm the String["carb", "sheriff", "mumchance"][2].
Run Code Online (Sandbox Code Playgroud) 我正在 Julia 中使用 DataFrames,并且想要过滤一些日期和日期时间列。为此,我需要运行数据作业时上个月的最后一天。
\n例如,如果今天的日期是Date("2021-07-21")
,我想获取2021-06-30
。
我一直在 Redshift SQL 中执行此操作,如下所示:
\nselect last_day(current_date - interval \'1 month\');\n\xe2\x94\x8c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x90\n\xe2\x94\x82 last_day \xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xa4\n\xe2\x94\x82 2021-06-30 \xe2\x94\x82\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x98\n
Run Code Online (Sandbox Code Playgroud)\n
\n