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



Пример 16.4


WITH RECURSIVE PARTS (ASSEMBLY, PART_NUMBER,

NUMBER_OF_PARTS, COST) AS

(SELECT CONTAINING_PART, CONTAINED_PART, 1, 0.00

FROM CAR

WHERE CONTAINING_PART = ''

UNION ALL

SELECT CAR.CONTAINING_PART, CAR.CONTAINED_PART,

CAR.NUMBER_OF_PARTS, CAR.NUMBER_OF_PARTS *

CAR.PART_COST

FROM CAR, PARTS

WHERE PARTS.PART_NUMBER = CAR.CONTAINING_PART)

SEARCH BREADTH FIRST

BY CONTAINING_PART, CONTAINED_PART

SET ORDER_COLUMN

SELECT PART_NUMBER, NUMBER_OF PARTS, COST

FROM PARTS

ORDER BY ORDER_COLUMN;




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