使用Proc SQL计算相关查询

时间:2015-08-14 16:12:42

标签: sql sas proc-sql

我有一个表master_t,其中包含customer_id和product_id以及flyer_section

table screenshot

我想算一下经常"回来"每个customer_id出现,到目前为止我有

proc sql
create table cust as
select
    distinct customer_id
    count((select(flyer_section from master_t where master_t.customer_id = distinct master_t.customer_id and flyer_section = 'back'))
from master_t
;
quit proc sql

我收到语法错误,我不确定它是否会起作用

谢谢。

1 个答案:

答案 0 :(得分:0)

对于您的查询,不应该这样的工作吗?

create table cust as
select
    customer_id
    count(flyer_section) as BackCount
from master_t
where upper(flyer_section) = 'BACK' 
      or lower(flyer_section) = 'front' 
      or lower(flyer_section) = 'inside'
group by customer_id