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 27 28 29 30
| SELECT Sum(A) AS AA, FK_Prefab
FROM (SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Left(Repere1,1) like 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
UNION ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Mid(Repere1,2,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
Union ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Mid(Repere1,3,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
Union ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Mid(Repere1,4,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
Union ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Mid(Repere1,5,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
Union ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Mid(Repere1,6,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
Union ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Mid(Repere1,7,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
Union ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Left(Repere2,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
UNION ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Mid(Repere2,2,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
Union ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Mid(Repere2,3,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
Union ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Mid(Repere2,4,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
Union ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Mid(Repere2,5,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
Union ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Mid(Repere2,6,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
Union ALL
SELECT Count(*) AS A, FK_Prefab FROM LignePrefab WHERE Mid(Repere2,7,1) LIKE 'A' AND FK_Prefab in (Select FK_Prefab From LignePrefab) Group BY FK_Prefab
)
GROUP BY FK_Prefab; |
Partager