[MySQL] NetApp OCI: Simple Query to Get Count of NFS and CIFS Shares Per Internal Volume

SELECT
    `name`,
    SUM(`isNFS`),
    SUM(`isCIFS`)
FROM(
    SELECT
        iv.name,
        iv.totalUsedCapacityMB,
       CASE
            WHEN ns.protocol = 'NFS' THEN 1
            ELSE 0
        END AS 'isNFS',
        CASE
            WHEN ns.protocol = 'CIFS' THEN 1
            ELSE 0
        END AS 'isCIFS'
    FROM internal_volume AS iv
    JOIN nas_file_share AS fs ON fs.internalVolumeId = iv.id
    JOIN nas_share AS ns ON ns.fileshareid = fs.id
    ) AS t0
GROUP BY t0.`name`



Comments