当前位置:网站首页>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 .
边栏推荐
- Write a program to process a list container of string type. Find a special value in the container 9.27: and delete it if found. Rewrite the above procedure with deque container.
- Kotlin learning quick start (7) -- wonderful use of expansion
- Enterprise custom form engine solution (XI) -- form rule engine 1
- POM in idea XML graying solution
- [combinatorics] recursive equation (case where the non-homogeneous part is exponential | example where the non-homogeneous part is exponential)
- ArrayList analysis 3: delete elements
- Brief introduction to the core functions of automatic penetration testing tool
- IntelliJ 2021.3 short command line when running applications
- STM32 realizes 74HC595 control
- Online assignment 3 of mobile Internet technology in the 20th autumn of electronic technology [standard answer]
猜你喜欢

Leetcode 669 pruning binary search tree -- recursive method and iterative method

Type conversion, variable
![[error reporting] omp: error 15: initializing libiomp5md dll, but found libiomp5md. dll already initialized.](/img/a0/4fc0e0741aad2885873e60f2af3387.jpg)
[error reporting] omp: error 15: initializing libiomp5md dll, but found libiomp5md. dll already initialized.

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

QT adjust win screen brightness and sound size

1164 Good in C

Deops入门

Implementation of Tetris in C language

Tensorboard quick start (pytoch uses tensorboard)

QT学习日记9——对话框
随机推荐
c# . Net tool ecosystem
Svn full backup svnadmin hotcopy
An example of HP array card troubleshooting
Play with fancy special effects. This AE super kit is for you
How to enforce parameters in PowerShell- How do I make parameters mandatory in PowerShell?
How to read the source code [debug and observe the source code]
RDS数据库的监测页面在哪看?
How SVN views modified file records
[combinatorics] recursive equation (example of solving recursive equation without multiple roots | complete process of solving recursive equation without multiple roots)
企业级自定义表单引擎解决方案(十一)--表单规则引擎1
[combinatorics] recursive equation (summary of the solution process of recursive equation | homogeneous | double root | non-homogeneous | characteristic root is 1 | exponential form | the bottom is th
互联网医院HIS管理平台源码,在线问诊,预约挂号 智慧医院小程序源码
kubernetes资源对象介绍及常用命令(四)
【RT-Thread】nxp rt10xx 设备驱动框架之--Audio搭建和使用
QT学习日记9——对话框
STM32 realizes 74HC595 control
Host based intrusion system IDS
Dagong 21 autumn "power plant electrical part" online operation 1 [standard answer] power plant electrical part
Kubernetes resource object introduction and common commands (V) - (NFS & PV & PVC)
How to purchase Google colab members in China