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
| WITH
CTE AS
(
SELECT ID,
COUNT(maColonne) CAT_NBR_DESCENDING
FROM dbo.T_CATALOG_CAT
WHERE CAT_LB > T1.CAT_LB
AND CAT_RB < T1.CAT_RB
)
SELECT CAT_ID,
CAST(SPACE(CAT_Level) + CAT_NAME AS VARCHAR(64)) AS CAT_NAME,
T1.CAT_Level,
T1.CAT_LB,
T1.CAT_RB,
T2.CAT_NBR_DESCENDING,
T1.CAT_DESCRIPTION,
T1.CAT_CREATIONDATE,
T1.CAT_STARTDATE,
T1.CAT_ENDDATE,
T1.CAT_RELEASED,
T1.CAT_RELEASEDDATE,
T1.CAT_URL,
T1.CAT_INVENTORY,
T1.CAT_COMMENT,
T1.CAT_DIMENSION,
T1.CAT_TYPE
FROM dbo.T_CATALOG_CAT T1
JOIN CTE_CAT_NBR_DESCENDING T2 ON T2.CAT_ID = T1.CAT_ID
ORDER BY T1.CAT_LB |
Partager