Michael Hoennig e4e1216a85 import-database-users-and-databases (#82)
Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: #82
Reviewed-by: Marc Sandlus <marc.sandlus@hostsharing.net>
2024-08-02 10:40:15 +02:00

24 lines
1.0 KiB
SQL

--liquibase formatted sql
-- ============================================================================
--changeset hs-global-object-statistics:1 endDelimiter:--//
-- ----------------------------------------------------------------------------
CREATE VIEW hs_statistics_view AS
select *
from (select count, "table" as "rbac-table", '' as "hs-table", '' as "type"
from rbacstatisticsview
union all
select to_char(count(*)::int, '9 999 999 999') as "count", 'objects' as "rbac-table", objecttable as "hs-table", '' as "type"
from rbacobject
group by objecttable
union all
select to_char(count(*)::int, '9 999 999 999'), 'objects', 'hs_hosting_asset', type::text
from hs_hosting_asset
group by type
union all
select to_char(count(*)::int, '9 999 999 999'), 'objects', 'hs_booking_item', type::text
from hs_booking_item
group by type
) as totals order by replace(count, ' ', '')::int desc;
--//