Введение в модель данных SQL




Пример 16.5


WITH RECURSIVE PARTS (PART_NUMBER,

NUMBER_OF_PARTS, COST) AS

(SELECT CONTAINED_PART, 1, 0.00

FROM CAR

WHERE CONTAINING_PART = ''

UNION ALL

SELECT CAR.CONTAINED_PART, CAR.NUMBER_OF_PARTS,

CAR.NUMBER_OF_PARTS * CAR.PART_COST

FROM CAR, PARTS

WHERE PARTS.PART_NUMBER = CAR.CONTAINING_PART)

CYRCLE CONTAINED_PART

SET CYCLEMARK TO 'Y' DEFAULT 'N'

USING CYRCLEPATH

SELECT PART_NUMBER, SUM(NUMBER_OF PARTS), SUM(COST)

FROM PARTS

ORDER BY PART_NUMBER;




Содержание  Назад  Вперед