当前位置:网站首页>Total number of MySQL statistics, used and unused
Total number of MySQL statistics, used and unused
2022-06-25 12:34:00 【mercenary's L】
MySQL:
surface storage_room,storage_rack
room:
rack:
sql Method 1 :
// After testing , This article sql Of count(*) The statistics are not accurate , If you need statistics, you need to write it yourself , I can test it
SELECT
a.*,b.id,b.storage_room_id,b.status,count(*),count(CASE WHEN status='2' THEN 0 END) qy,count(CASE WHEN status='3' THEN 0 END) wqy
FROM
wd_storage_room a
LEFT JOIN wd_storage_rack b ON a.id = b.storage_room_id
// This article sql To sum up to the top sql And it's written
SELECT count(*),count(CASE WHEN status='2' THEN 0 END) qy,count(CASE WHEN status='3' THEN 0 END) wqy FROM wd_storage_rack
sql Method 2 :// This item is on jeecgboot Under the framework of sql
SELECT
a.*,
(SELECT COUNT(ac.id) FROM wd_storage_rack ac WHERE ac.storage_room_id = a.id) AS storageRackAllNum,
(SELECT COUNT(ac.id) FROM wd_storage_rack ac WHERE ac.storage_room_id = a.id AND ac.`status` = 2) AS storageRackUseNum,
(SELECT COUNT(ac.id) FROM wd_storage_rack ac WHERE ac.storage_room_id = a.id AND ac.`status` = 3) AS storageRackUnUseNum
FROM
wd_storage_room a
ORDER BY create_time DESCNewly changed sql

SELECT
a.id,a.storage_rack_id,a.code,a.title,a.site,a.enable,
count(distinct b.id) as storageRackAllNum,
count(distinct CASE WHEN b.status='1' THEN 0 END) as storageRackUseNum,
count(distinct CASE WHEN b.status='2' THEN 0 END) as storageRackUnUseNum
FROM
((SELECT * FROM wd_storage_room ) a
left join (SELECT * FROM wd_storage_rack ) b
on FIND_IN_SET(b.id, a.storage_rack_id))
<if test="storageRoom.title != null and storageRoom.title != ''">
where
a.title=${storageRoom.title}
</if>
group by a.id边栏推荐
- Learning notes 2022 overview | automatic graph machine learning, describing AGML methods, libraries and directions
- 揭秘GaussDB(for Redis):全面對比Codis
- 一款好用的印章设计工具 --(可转为ofd文件)
- PHP replaces the key of a two-dimensional array with a specified element value
- Service charge and time setting code sharing involved in crmeb withdrawal process
- Huile optimization system -- sharing of secondary development source code of huile optimization app system
- Gradle knowledge points
- What is principal component analysis? Dimension reduction of classical case analysis variables
- Penetration tool environment -- use of cknife Chinese kitchen knife
- thinkphp3.2.5 GIF. class. php for php7.4
猜你喜欢

The first techo day Tencent technology open day in 2022 will be held online on June 28

A commonly used statistical modeling method -- difference analysis

Zhangxiaobai's way of penetration (V) -- detailed explanation of upload vulnerability and parsing vulnerability

Flutter common commands and problems

Why do we do autocorrelation analysis? Explain application scenarios and specific operations

How do super rookies get started with data analysis?

Navicat premium view password scheme

20. MVVM command binding of WPF

ECSHOP video list_ ECSHOP uploading video, video classification, video list playing video function

Explain AHP in human language (very detailed principle + simple tool implementation)
随机推荐
Thinkphp3 count ` *'problem
Wait for the end of the network request in the uniapp Onshow method before executing the subsequent code content
Découvrir gaussdb (pour redis): une comparaison complète avec Codis
【数据中台】数据中台的OneID是个什么鬼,主数据它不香吗?
Navicat premium view password scheme
Some fields are ignored in tp6 query
R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用epiDisplay包的lrtest函数执行多个模型似然比检验对比两个模型的性能是否有差异
Pycaret successfully resolved the problem that 'sklearn model_ selection._ Search 'import name "\u check\u param\u grid"
Fun pocket mall -- sharing the development source code of fun pocket app system
K8s, docker compose install MySQL 8.0.18
ECSHOP upload video_ ECSHOP video list, video classification, video related product guide
Gradle knowledge points
Mpai data science platform SVM support vector machine classification \ explanation of regression parameter adjustment
ECSHOP commodity wholesale multi attribute multi specification multi inventory batch purchase ECSHOP wholesale plug-in ECSHOP multi attribute order
Upgrade opsenssh to 8.8p1
R language dplyr package summary_ The at function calculates the count number, mean and median of multiple data columns (specified by vectors) in the dataframe data, and specifies na RM parameter, spe
Linear regression of common mathematical modeling models for College Students
PHP parsing QR code content
Dark horse shopping mall ---1 Project introduction - environment construction
Thinkphp3 reinforcement i() function filter single quotation marks