当前位置:网站首页>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] construction and use of --hwtimer of NXP rt10xx device driver framework
- link preload prefetch
- STM32H7 HAL库SPI DMA发送一直处于busy的解决办法
- [combinatorics] generating function (linear property | product property)
- Luogu: p1155 [noip2008 improvement group] double stack sorting (bipartite graph, simulation)
- 国内如何购买Google Colab会员
- 互联网医院HIS管理平台源码,在线问诊,预约挂号 智慧医院小程序源码
- Graduation summary
- Analyse ArrayList 3: suppression d'éléments
- 面试官:值为 nil 为什么不等于 nil ?
猜你喜欢

PS screen printing brush 131, many illustrators have followed suit

1164 Good in C

【RT-Thread】nxp rt10xx 设备驱动框架之--rtc搭建和使用

Collection of the most beautiful graduation photos in the graduation season, collection of excellent graduation photos

QT学习日记9——对话框

1147_ Makefile learning_ Target files and dependent files in makefile

1146_ SiCp learning notes_ exponentiation

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

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

Kubernetes resource object introduction and common commands (V) - (NFS & PV & PVC)
随机推荐
PUT vs. POST for Uploading Files - RESTful API to be Built Using Zend Framework
一位普通程序员一天工作清单
How to enforce parameters in PowerShell- How do I make parameters mandatory in PowerShell?
Installation and configuration of network hard disk NFS
QT learning diary 9 - dialog box
kubernetes资源对象介绍及常用命令(三)
TCP拥塞控制详解 | 3. 设计空间
PR second time
Qt调节Win屏幕亮度和声音大小
数仓任务里面 跑SQL任务的时候用的数据库账号是在哪里配置的
SQL injection database operation foundation
Swm32 series Tutorial 4 port mapping and serial port application
SWM32系列教程4-端口映射及串口应用
AcWing 4489. Longest subsequence
Applet setting multi account debugging
[combinatorics] recursive equation (example of solving recursive equation without multiple roots | complete process of solving recursive equation without multiple roots)
Y is always discrete and can't understand, how to solve it? Answer: read it several times
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.
Implementation of Tetris in C language
[UE4] brush Arctic pack high quality Arctic terrain pack