From 014bc5a6de7cafaf450fccac01543d8457186422 Mon Sep 17 00:00:00 2001 From: Ronny Wyss Date: Sat, 2 Mar 2019 17:29:21 +0100 Subject: [PATCH] VIEW erstellt --- MySQL/View_UsagePerLocation.sql | 14 ++++++++++++++ MySQL/View_UsagePerPod.sql | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 MySQL/View_UsagePerLocation.sql create mode 100644 MySQL/View_UsagePerPod.sql diff --git a/MySQL/View_UsagePerLocation.sql b/MySQL/View_UsagePerLocation.sql new file mode 100644 index 0000000..3f51203 --- /dev/null +++ b/MySQL/View_UsagePerLocation.sql @@ -0,0 +1,14 @@ +use inventarisierungsloesung; +DROP VIEW IF EXISTS v_usageperlocation; + +SELECT COUNT(devices_id_fk), 'devices_id_fk' FROM interfaces +GROUP BY devices_id_fk; + +CREATE VIEW v_usageperlocation AS + +SELECT i.interface_id, l.designation, COUNT(i.devices_id_fk) AS 'Anzahl belegter Port' FROM interfaces i INNER JOIN devices d ON i.devices_id_fk = d.device_id +INNER JOIN location l +ON d.location_fk = l.location_id +GROUP BY i.devices_id_fk; + +SELECT * FROM v_usageperlocation; \ No newline at end of file diff --git a/MySQL/View_UsagePerPod.sql b/MySQL/View_UsagePerPod.sql new file mode 100644 index 0000000..08c5351 --- /dev/null +++ b/MySQL/View_UsagePerPod.sql @@ -0,0 +1,14 @@ +use inventarisierungsloesung; +DROP VIEW IF EXISTS v_usageperpod; + +CREATE VIEW v_usageperpod (interface_id, ldesignation,idevices_id_fk , pdesignation) AS + +SELECT i.interface_id, l.designation, COUNT(i.devices_id_fk) AS 'Anzahl belegter Port', p.designation FROM interfaces i +INNER JOIN devices d +ON i.devices_id_fk = d.device_id +INNER JOIN location l +ON d.location_fk = l.location_id +INNER JOIN pointofdelivery p +ON l.location_id = p.location_fk; + +SELECT * FROM v_usageperpod; \ No newline at end of file