原始表中有字断 start_date(到天的) ,type(类型) cust_id(用户id) time(时长)现在要的结果 是 每个月,某类型的客户数量和总时长我写的SQL是create table b as
select trunc(start_date,'mm') as start_date, sum(time) as time,
count ( distinct cust_id) as cust_num ,type
from A
group by start_date,type;但出来的结果不是我想要的 type在原表中是1到10 一共10个类型 但B表中type从1到几百不等
请高手指教应该怎么写
select trunc(start_date,'mm') as start_date, sum(time) as time,
count ( distinct cust_id) as cust_num ,type
from A
group by start_date,type;但出来的结果不是我想要的 type在原表中是1到10 一共10个类型 但B表中type从1到几百不等
请高手指教应该怎么写
不过我后来又试了次 type的结果还是乱七八糟的