当前位置:网站首页>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 .
边栏推荐
- How SVN views modified file records
- TCP拥塞控制详解 | 3. 设计空间
- Deops入门
- What is the difference between cloud server and cloud virtual machine
- STM32 realizes 74HC595 control
- VM11289 WAService. js:2 Do not have __ e handler in component:
- 毕业总结
- Detailed explanation of common network attacks
- 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.
- Open vsftpd port under iptables firewall
猜你喜欢

How to purchase Google colab members in China

Is AI too slow to design pictures and draw illustrations? 3 sets of practical brushes to save you

互聯網醫院HIS管理平臺源碼,在線問診,預約掛號 智慧醫院小程序源碼

Redis: operation commands for list type data
![[RT thread] NXP rt10xx device driver framework -- RTC construction and use](/img/19/91a9d84ba84f81ef125c33eb4007bc.png)
[RT thread] NXP rt10xx device driver framework -- RTC construction and use

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

Leetcode 538 converts binary search tree into cumulative tree -- recursive method and iterative method

vs2013已阻止安装程序,需安装IE10

Unity notes unityxr simple to use

Design e-commerce spike
随机推荐
WEB-UI自动化测试-最全元素定位方法
互联网医院HIS管理平台源码,在线问诊,预约挂号 智慧医院小程序源码
毕业总结
Hongmeng fourth training
Where is the monitoring page of RDS database?
Notes on problems -- watching videos on edge will make the screen green
TCP congestion control details | 3 design space
Where is the database account used when running SQL tasks in data warehouse tasks configured
Kubernetes resource object introduction and common commands (4)
Rsync remote synchronization
[RT thread] NXP rt10xx device driver framework -- RTC construction and use
Play with fancy special effects. This AE super kit is for you
Financial management (Higher Vocational College) financial management online Assignment 1 in autumn 20
The third day of writing C language by Yabo people
Simple configuration of postfix server
PS screen printing brush 131, many illustrators have followed suit
[combinatorics] recursive equation (special solution example 1 Hannover tower complete solution process | special solution example 2 special solution processing when the characteristic root is 1)
Stm32h7 Hal library SPI DMA transmission has been in busy solution
Leetcode 108 converts an ordered array into a binary search tree -- recursive method
TensorBoard快速入门(Pytorch使用TensorBoard)