Excel Pivot Statistics

 1 Add a list of varieties and fill in the formula =IFERROR(LEFT(C2,IFERROR(FIND("(",C2)-1,FIND("(",C2)-1)),C2) to get the Chinese part of the name specification.
2 Select the data range (including column names) to be counted, and select Insert - PivotTable (leftmost) from the toolbar menu.
3 The Pivot Table dialog box pops up, the default value is enough, click OK. Set column and statistic values.
Get a pivot table.
--http://jingyan.baidu.com/article/f54ae2fc042cc41e92b849cc.html find string
--http://jingyan.baidu.com/article/624e7459aa90e434e8ba5a8a.html
--http://jingyan.baidu.com/article/b2c186c8f7691fc46ef6ff20.html IF function used
--=IFERROR(LEFT(D2,FIND("(",D2)-1),D2)
--===IFERROR(LEFT(C2,IFERROR(FIND("(",C2)-1,FIND("(",C2)-1)),C2) Take the characters of the right cell and intercept the starting number on the left To "(""(" position minus one length sub-character. If there is an error, the left character is directly taken.
--====ROUND(C5/B5,2) keep 2 decimal places
--==================================================== ==Separation line================
create table zyh_test(
xsrq varchar2(50),
pz   varchar2(50),
wzmcjgg varchar2(200),
xssl  number,
xsdj  number,
xsje  number
);
select * from zyh_test for update;
delete from zyh_test;
select substr('Australian flame wood (10cm)',1,instr('Australian flame wood (10cm)','(')-1)from dual;
select instr('Australian flame wood (10cm)','(') from dual;
-----
update zyh_test a set a.pz = substr(a.wzmcjgg,1,instr(a.wzmcjgg,'(')-1) where a.pz is null;
update zyh_test a set a.pz = substr(a.wzmcjgg,1,instr(a.wzmcjgg,'(')-1) where a.pz is null;
update zyh_test a set a.pz = a.wzmcjgg where a.pz is null;
 
select * from zyh_test a where a.pz is null;
 
select a.pz varieties,
       sum(nvl(a.xssl, 0)) number,
       sum(nvl(a.xsje, 0)) amount,
       round(sum(nvl(a.xsje, 0)) / sum(nvl(a.xssl, 0)), 2) Average unit price
  from zyh_test a
 group by a.pz;
 
 select * from zyh_test a where a.pz='黑酸枝'
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326231356&siteId=291194637