summaryrefslogtreecommitdiff
path: root/graphs/sql/maas/req01.sql
blob: d017c9387f3a1645e84472f7104835885fc0f604 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CREATE VIEW memorin.devices_summary AS
    SELECT
    total_devices,
    active_devices,
    total_devices - active_devices AS inactive_devices
    FROM
    (
        SELECT COUNT(*) AS total_devices
        FROM memorin.devices
    ) AS d,
    (
        SELECT COUNT(*) AS active_devices
        FROM memorin.devices
        WHERE deactivated_at IS NULL
    ) AS a;