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



Пример 16.3


WITH RECURSIVE PARTS (PART_NUMBER,

NUMBER_OF_PARTS, COST) AS

(SELECT CONTAINED_PART, 1, 0.00 (a)

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)

SELECT PART_NUMBER, SUM(NUMBER_OF PARTS),

SUM(COST) (b)

FROM PARTS

GROUP BY PART_NUMBER;




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