当前位置:网站首页>Five problems of database operation in commodity supermarket system
Five problems of database operation in commodity supermarket system
2022-07-03 17:39:00 【CSDN Q & A】
Commodity management system , Three tables ,

( explain : Commodity list (csb_sp) It's a zipper Watch , Start date (qsrq)、 End date (jsrq) Record the change of sales unit price by date range .)
1、 Inquire about 2021 Since the start of the year , Sales unit price changes of all goods , Display information : Name of commodity 、 Commodity type 、 Commodity unit 、 Start date 、 End date 、 item pricing .
2、 Inquire about 2021 Warehousing of all goods since the beginning of the year , Display information : Name of commodity 、 Commodity type 、 Total warehousing 、 Warehousing times 、 Total purchase expenditure . And arrange them in descending order according to the total warehousing amount .
3、 Inquire about 2021 year 3 Commodity transactions in the month , Display information : Name of commodity 、 Commodity type 、 Total volume of transactions 、 Total transaction amount . In descending order of transaction amount .
4、 Query the transaction volume of cash payment and non cash payment in the first quarter , Display information : month 、 Number of cash payments 、 Number of non cash payments 、 Proportion of cash payment transaction amount . Arrange in ascending order by month .
5、 The average daily sales volume since the beginning of the year has reached 100 Or the average daily sales will reach 3000 Yuan goods , Display information : Name of commodity 、 Commodity type 、 Average daily sales 、 Average daily sales .
Take the answer :
These problems should be involved in more basic sql knowledge , Don't think too complicated .
Specific code :
-- problem 1select spmc,splx,spdw,qsrq,jsrq,xsdj from csb_sp where qsrq >= '2021-01-1' ;-- problem 2select b.spmc,b.splx,sum(a.rksl) as rkzl,count(a.spbh) as rkcs,sum(a.grdj) as zczje from sp_rkjl aleft join csb_sp b on a.spbh = b.spbh where rkrq >= '2021-01-1' group by b.spmc,b.splx order by sum(a.rksl) desc ;-- problem 3 This needs to consider the change of unit price select b.spmc,b.splx,sum(jysl) as jyzl,sum(a.jysl*b.xsdj) as jyzje from sp_jyjl a left join csb_sp b on a.spbh = b.spbh and a.jyrq between b.qsrq and b.jsrqwhere a.jyrq between '2021-03-01' and '2021-03-31'group by b.spmc,b.splx order by sum(a.jysl*b.xsdj) desc-- problem 4select right(date_format(jyrq, '%Y%m'),2),sum(case when fkfs = 0 then 1 else 0 end ) xjcs,sum(fkfs) as fxjfkcs -- be based on fkfs This field is int Type of writing ,sum(case when fkfs = 0 then a.jysl*b.xsdj else 0 end )/sum(a.jysl*b.xsdj) xjfrjyjezb from sp_jyjl a left join csb_sp b on a.spbh = b.spbh and a.jyrq between b.qsrq and b.jsrqwhere right(date_format(jyrq, '%Y%m'),2) between '01' and '03'group by right(date_format(jyrq, '%Y%m'),2) order by right(date_format(jyrq, '%Y%m'),2) -- problem 5select t1.spmc,t1.splx,avg(jyzl) ,avg(jyzje ) from (select a.jyrq,b.spmc,b.splx,sum(jysl) as jyzl,sum(a.jysl*b.xsdj) as jyzje from sp_jyjl a left join csb_sp b on a.spbh = b.spbh and a.jyrq between b.qsrq and b.jsrqwhere a.jyrq >= '2021-01-01' group by b.spmc,b.splx ,a.jyrq ) t1 group by t1.spmc,t1.splx having avg(jyzl) >=100 or avg(jyzje )>=3000Because there is no data content and table structure to refer to , All written contents need subsequent verification , If there is a problem , Please contact directly .
边栏推荐
- [RT thread] NXP rt10xx device driver framework -- Audio construction and use
- List of financial products in 2022
- Qt调节Win屏幕亮度和声音大小
- What is the difference between cloud server and cloud virtual machine
- QT adjust win screen brightness and sound size
- An example of HP array card troubleshooting
- kubernetes资源对象介绍及常用命令(三)
- Assignment examination questions of advanced English (III) for the course examination of Fujian Normal University in February 2022
- Luogu: p2685 [tjoi2012] Bridge
- 1164 Good in C
猜你喜欢

kubernetes资源对象介绍及常用命令(五)-(NFS&PV&PVC)

Getting started with deops

鸿蒙第四次培训

Type conversion, variable

Kubernetes resource object introduction and common commands (4)

Design e-commerce spike

IntelliJ 2021.3 short command line when running applications

kubernetes资源对象介绍及常用命令(三)

聊聊支付流程的设计与实现逻辑
![[UE4] brush Arctic pack high quality Arctic terrain pack](/img/e7/bc86bd8450b0b2bdec8980a2aa1a10.jpg)
[UE4] brush Arctic pack high quality Arctic terrain pack
随机推荐
鸿蒙第四次培训
Assignment examination questions of advanced English (III) for the course examination of Fujian Normal University in February 2022
设计电商秒杀
RDS数据库的监测页面在哪看?
Remote office tools sharing | community essay solicitation
[combinatorics] recursive equation (example of solving recursive equation without multiple roots | complete process of solving recursive equation without multiple roots)
面试官:值为 nil 为什么不等于 nil ?
Internet Hospital his Management Platform source, online Inquiry, appointment Registration Smart Hospital Small program source
Vs code plug-in korofileheader
Qt调节Win屏幕亮度和声音大小
Simple use of unity pen XR grab
Internet hospital his management platform source code, online consultation, appointment registration smart hospital applet source code
Tensorboard quick start (pytoch uses tensorboard)
PHP returns 500 errors but no error log - PHP return 500 error but no error log
Web-ui automated testing - the most complete element positioning method
Getting started with deops
[combinatorics] recursive equation (general solution structure of recursive equation with multiple roots | linear independent solution | general solution with multiple roots | solution example of recu
AcWing 4489. 最长子序列
Leetcode 538 converts binary search tree into cumulative tree -- recursive method and iterative method
[UE4] brush Arctic pack high quality Arctic terrain pack