今天在同学的告知下,做时间的筛选,选出那些发票明细中时间在发票时间之前的发票编号
create table mxtmp(fp_nid string,je double) Row format delimited fields terminated by ',';
insert into table mxtmp select fp_nid,sum(je), from hwmx1 group by fp_nid;
create table mxdate(fp_nid string,je double,mxdate string) Row format delimited fields terminated by ',';
select mxtmp.fp_nid,mxtmp.je,hwmx1.date_key from mxtmp join hwmx1 on mxtmp.fp_nid=hwmx1.fp_nid;//这一条会执行重复的id搜索出很多数据 不好用
insert into table mxdate select fp_nid,sum(je),date_key from hwmx1 group by fp_nid,date_key;
//与zzsfp的日期不匹配的发票
create table edate(fp_nid string );
insert into table edate select zzsfp1.fp_nid from zzsfp1 join mxdate on zzsfp1.fp_nid=mxdate.fp_nid where zzsfp1.kpyf!=mxdate.mxdate;
//通过发票编号,筛选出开这些发票的公司
select zzsfp1.xf_id from zzsfp1 join edate on zzsfp1.fp_nid=edate.fp_nid group by zzsfp1.xf_id;
这样的结果有些多,我有点不知所措了,这个数量级有点大。