1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| -- pour les tables plus ou moins remplies et toutes les autres
WITH
T1 AS
(SELECT Id_Tables, COUNT(*) AS N
FROM Positions),
T2 AS
(SELECT MAX(N) AS MX, MIN(N) AS MN
FROM T1)
SELECT T1.Id_Table, N AS NOMBRE, 'PLUS' AS Remplie
FROM T1
INNER JOIN T2
ON T1.N = T2.MX
UNION ALL
SELECT T1.Id_Table, N, 'MOINS' AS Remplie
FROM T1
INNER JOIN T2
ON T1.N = T2.MN
UNION ALL
SELECT T1.Id_Table, N, NULL AS Remplie
FROM T1
WHERE N NOT IN (SELECT MX
FROM T2
UNION ALL
SELECT MN
FROM T2)
ORDER BY NOMBRE DESC |
Partager