当前位置:网站首页>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 .
边栏推荐
- Simple use of unity pen XR grab
- RedHat 6.2 configuring ZABBIX
- SQL injection database operation foundation
- [combinatorics] recursive equation (case where the non-homogeneous part is exponential | example where the non-homogeneous part is exponential)
- AcWing 3438. 数制转换
- QT adjust win screen brightness and sound size
- Website with JS doesn't work in IE9 until the Developer Tools is activated
- Collection of the most beautiful graduation photos in the graduation season, collection of excellent graduation photos
- [UE4] brush Arctic pack high quality Arctic terrain pack
- Design e-commerce spike
猜你喜欢

2021 ICPC regional competition (Shanghai) g.edge groups (tree DP)

Introduction to SolidWorks gear design software tool geartrax

Applet setting multi account debugging

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

Wechat applet for the first time

Kubernetes resource object introduction and common commands (4)

Is AI too slow to design pictures and draw illustrations? 3 sets of practical brushes to save you
![[RT thread] construction and use of --hwtimer of NXP rt10xx device driver framework](/img/df/a7719bcb00ff66e21f3a391ab94573.png)
[RT thread] construction and use of --hwtimer of NXP rt10xx device driver framework

TensorBoard快速入门(Pytorch使用TensorBoard)

Tensorboard quick start (pytoch uses tensorboard)
随机推荐
QT learning diary 9 - dialog box
ES6类的继承
Assignment examination questions of advanced English (III) for the course examination of Fujian Normal University in February 2022
STM32 realizes 74HC595 control
Website with JS doesn't work in IE9 until the Developer Tools is activated
鸿蒙第四次培训
Swm32 series Tutorial 4 port mapping and serial port application
c# . Net tool ecosystem
Tensorboard quick start (pytoch uses tensorboard)
QT adjust win screen brightness and sound size
数学公式(测试)
Hongmeng fourth training
A day's work list of an ordinary programmer
Draw some simple graphics with MFC
[combinatorics] recursive equation (the problem of solving recursive equation with multiple roots | the problem is raised)
Enterprise custom form engine solution (XI) -- form rule engine 1
Web-ui automated testing - the most complete element positioning method
kubernetes资源对象介绍及常用命令(四)
Comparison of kotlin collaboration + retro build network request schemes
Managing multiple selections with MVVM - managing multiple selections with MVVM