小编Mer*_*lin的帖子

Redshift PostgresQL语法:命名为window子句有效吗?

我怀疑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'语法 - 我想我应该把它作为答案.

这是一个关于Postgres名为windows的SO答案

这是关于WINDOW AS ()语法的Postgres 8.4文档

amazon-redshift

5
推荐指数
1
解决办法
279
查看次数

julia 正则表达式匹配文件中的行,例如 grep

我想看到 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,文件中每个条目的第一行都是大写单词。

julia

5
推荐指数
2
解决办法
2338
查看次数

redshift:通过窗口分区计算不同的客户

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)

sql amazon-redshift

4
推荐指数
2
解决办法
7828
查看次数

Julia:数组元素的字符串插值

我可以将变量插入字符串中,以使用其他文本打印该值,如下所示:

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)

arrays julia

3
推荐指数
1
解决办法
685
查看次数

朱莉娅日期:上个月的最后一天

我正在 Julia 中使用 DataFrames,并且想要过滤一些日期和日期时间列。为此,我需要运行数据作业时上个月的最后一天。

\n

例如,如果今天的日期是Date("2021-07-21"),我想获取2021-06-30

\n

我一直在 Redshift SQL 中执行此操作,如下所示:

\n
select 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

date julia

1
推荐指数
1
解决办法
430
查看次数

标签 统计

julia ×3

amazon-redshift ×2

arrays ×1

date ×1

sql ×1