当前位置:网站首页>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 )>=3000
Because 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 .
边栏推荐
- Simple use of unity pen XR grab
- 【JokerのZYNQ7020】DDS_ Compiler。
- Leetcode13. Roman numeral to integer (three solutions)
- Apache service suspended asynchronous acceptex failed
- LeetCode13.罗马数字转整数(三种解法)
- Create a new file from templates with bash script - create new file from templates with bash script
- Design e-commerce spike
- STM32 realizes 74HC595 control
- 鸿蒙第三次培训
- The gbase 8A database does not support the DB2 function value (column_name, 0) cluster syntax
猜你喜欢
Play with fancy special effects. This AE super kit is for you
Deops入门
Luogu: p2685 [tjoi2012] Bridge
MySQL grouping query
TensorBoard快速入门(Pytorch使用TensorBoard)
Implementation of Tetris in C language
Kubernetes resource object introduction and common commands (4)
1146_ SiCp learning notes_ exponentiation
Internet hospital his management platform source code, online consultation, appointment registration smart hospital applet source code
[RT thread] construction and use of --hwtimer of NXP rt10xx device driver framework
随机推荐
List of financial products in 2022
Kubernetes resource object introduction and common commands (V) - (NFS & PV & PVC)
聊聊支付流程的设计与实现逻辑
Stm32h7 Hal library SPI DMA transmission has been in busy solution
Select 3 fcpx plug-ins. Come and see if you like them
Host based intrusion system IDS
毕业总结
[combinatorics] recursive equation (special solution form | special solution solving method | special solution example)
[combinatorics] recursive equation (the problem of solving recursive equation with multiple roots | the problem is raised)
kubernetes资源对象介绍及常用命令(三)
Swm32 series Tutorial 4 port mapping and serial port application
MinGW compile boost library
[set theory] order relation: summary (partial order relation | partial order set | comparable | strictly less than | covering | hasto | total order relation | quasi order relation | partial order rela
An example of HP array card troubleshooting
RedHat 6.2 configuring ZABBIX
绝对定位时元素水平垂直居中
AcWing 3438. Number system conversion
VM11289 WAService. js:2 Do not have __ e handler in component:
Cloud primordial weekly | CNCF released the 2021 cloud primordial development status report, which was released on istio 1.13
Hongmeng third training