Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dankal-data-view
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
仲光辉
dankal-data-view
Commits
a3c2f441
You need to sign in or sign up before continuing.
Commit
a3c2f441
authored
May 15, 2025
by
mercymodest
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:- add sql
parent
7896e945
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
塞纳设备版本统计.sql
数据统计SQL/塞纳设备版本统计.sql
+69
-0
No files found.
数据统计SQL/塞纳设备版本统计.sql
0 → 100644
View file @
a3c2f441
-- 机构设备数量
-- 机构设备数量
SELECT
COUNT
(
*
)
FROM
t_device
AS
d
WHERE
d
.
org_id
=
1843925053672611842
AND
d
.
is_delete
=
0
;
-- 机构全部设备版本分布
SELECT
o
.
org_name
AS
`机构名称`
,
d
.
current_device_application_version
AS
`设备版本`
,
COUNT
(
d
.
device_id
)
AS
`设备数量`
FROM
t_device
AS
d
INNER
JOIN
t_org
AS
o
ON
d
.
org_id
=
o
.
org_id
WHERE
d
.
org_id
=
1843925053672611842
AND
d
.
is_delete
=
0
GROUP
BY
d
.
current_device_application_version
ORDER
BY
`设备数量`
DESC
;
-- 机构已激活设备版本分布
SELECT
o
.
org_name
AS
`机构名称`
,
d
.
current_device_application_version
AS
`设备版本`
,
COUNT
(
d
.
device_id
)
AS
`设备数量`
FROM
t_device
AS
d
INNER
JOIN
t_org
AS
o
ON
d
.
org_id
=
o
.
org_id
LEFT
JOIN
t_user_device_codes
AS
udc
ON
udc
.
device_id
=
d
.
device_id
AND
udc
.
is_delete
=
0
WHERE
d
.
org_id
=
1843925053672611842
AND
d
.
is_delete
=
0
AND
udc
.
user_device_code_id
IS
NOT
NULL
GROUP
BY
d
.
current_device_application_version
ORDER
BY
`设备数量`
DESC
;
SELECT
SUM
(
`设备数量`
)
FROM
(
SELECT
o
.
org_name
AS
`机构名称`
,
d
.
current_device_application_version
AS
`设备版本`
,
COUNT
(
d
.
device_id
)
AS
`设备数量`
FROM
t_device
AS
d
INNER
JOIN
t_org
AS
o
ON
d
.
org_id
=
o
.
org_id
INNER
JOIN
t_user_device_codes
AS
udc
ON
udc
.
device_id
=
d
.
device_id
AND
udc
.
is_delete
=
0
WHERE
d
.
org_id
=
1843925053672611842
AND
d
.
is_delete
=
0
GROUP
BY
d
.
current_device_application_version
ORDER
BY
`设备数量`
DESC
)
AS
t
;
-- 机构未激活设备版本分布
SELECT
o
.
org_name
AS
`机构名称`
,
d
.
current_device_application_version
AS
`设备版本`
,
COUNT
(
d
.
device_id
)
AS
`设备数量`
FROM
t_device
AS
d
INNER
JOIN
t_org
AS
o
ON
d
.
org_id
=
o
.
org_id
LEFT
JOIN
t_user_device_codes
AS
udc
ON
udc
.
device_id
=
d
.
device_id
AND
udc
.
is_delete
=
0
WHERE
d
.
org_id
=
1843925053672611842
AND
d
.
is_delete
=
0
AND
udc
.
user_device_code_id
IS
NULL
GROUP
BY
d
.
current_device_application_version
ORDER
BY
`设备数量`
DESC
;
SELECT
SUM
(
`设备数量`
)
FROM
(
SELECT
o
.
org_name
AS
`机构名称`
,
d
.
current_device_application_version
AS
`设备版本`
,
COUNT
(
d
.
device_id
)
AS
`设备数量`
FROM
t_device
AS
d
INNER
JOIN
t_org
AS
o
ON
d
.
org_id
=
o
.
org_id
LEFT
JOIN
t_user_device_codes
AS
udc
ON
udc
.
device_id
=
d
.
device_id
AND
udc
.
is_delete
=
0
WHERE
d
.
org_id
=
1843925053672611842
AND
d
.
is_delete
=
0
AND
udc
.
user_device_code_id
IS
NULL
GROUP
BY
d
.
current_device_application_version
ORDER
BY
`设备数量`
DESC
)
AS
t
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment