0% found this document useful (0 votes)
2 views2 pages

Assignment 3

The document outlines an assignment requiring the insertion of 100 records into two database tables, EMP and ASG, using assumed values. It includes SQL queries to retrieve project names and budgets based on their location, as well as to categorize projects by budget ranges across four different sites. The assignment emphasizes the application of predicates in executing these queries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Assignment 3

The document outlines an assignment requiring the insertion of 100 records into two database tables, EMP and ASG, using assumed values. It includes SQL queries to retrieve project names and budgets based on their location, as well as to categorize projects by budget ranges across four different sites. The assignment emphasizes the application of predicates in executing these queries.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

2022UCD2110

Assignment 3
Consider the two relations EMP and ASG given in the the image. Insert 100 records in each by
assumed values. Also Apply several predicates to execute the queries, given four different sites.

INSERT INTO EMP (ENO, ENAME, TITLE)


VALUES
('E4', 'J. Miller', 'Programmer'),
('E5', 'B. Casey', 'Syst. Anal.'),
-- Add 100 entries dynamically;
INSERT INTO ASG (ENO, PNO, RESP, DUR, BUDGET, LOCATION)
VALUES
('E1', 'P1', 'Manager', 12, 200000, 'New York'),
('E2', 'P2', 'Analyst', 24, 250000, 'Chicago'),
-- Add 100 entries dynamically;
1. The first query is issued at four sites and finds the names and budgets of projects given their
location.
SELECT ASG.PNO, ASG.BUDGET, ASG.LOCATION
FROM ASG
WHERE ASG.LOCATION = 'New York';

2. The second query is for Those projects that have a budget of less than or equal to $200,000 are
managed at one site, budget between $240000 and $ 320000 are managed at second site whereas
those between $350000 and $ 450000 budgets are managed at a third site, whereas those with
larger budgets are managed at a fourth site.
SELECT
PNO,
BUDGET,
CASE
WHEN BUDGET <= 200000 THEN 'Site 1'
WHEN BUDGET BETWEEN 240000 AND 320000 THEN 'Site 2'
WHEN BUDGET BETWEEN 350000 AND 450000 THEN 'Site 3'
ELSE 'Site 4'
END AS SITE
FROM ASG;

You might also like