Order Schedule | SQL Interview Question

 DML Script:


DROP TABLE IF EXISTS Orders;

DROP TABLE IF EXISTS ManufacturingTimes;

GO


CREATE TABLE  Orders

(

OrderID        INTEGER PRIMARY KEY,

Product        VARCHAR(100) NOT NULL,

DaysToDeliver  INTEGER NOT NULL

);

GO


CREATE TABLE  ManufacturingTimes

(

Product            VARCHAR(100),

Component          VARCHAR(100),

DaysToManufacture  INTEGER NOT NULL,

PRIMARY KEY (Product, Component)

);

GO


INSERT INTO  Orders (OrderID, Product, DaysToDeliver) VALUES

(1, 'Aurora', 7),

(2, 'Twilight', 3),

(3, 'SunRay', 9);

GO


INSERT INTO  ManufacturingTimes (Product, Component, DaysToManufacture) VALUES

('Aurora', 'Photon Coil', 7),

('Aurora', 'Filament', 2),

('Aurora', 'Shine Capacitor', 3),

('Aurora', 'Glow Sphere', 1),

('Twilight', 'Photon Coil', 7),

('Twilight', 'Filament', 2),

('SunRay', 'Shine Capacitor', 3),

('SunRay', 'Photon Coil', 1);

GO



select * from Orders


select * from ManufacturingTimes


Detailed Explanation: https://youtu.be/Krqf1DvNFg8

Comments

Popular posts from this blog

50 Essential SQL Questions to Land Your Dream Job

How to find all the customers who placed orders on three consecutive days | SQL Scenario questions

ACCENTURE SQL INTERVIEW QUESTION | Change the ProductIDs