SQL Sherya
SQL Sherya
DefaultPassword – varchar
Solution –
);
2. Write SQL Query to Insert at least 2 records into the table named Underwriter
Solution –
VALUES
3. As an underWriter, I should be able to create a table named Insurance for storing Insurance
details for a Vehicle in Database StarProtect:
PolicyNo: AutoIncremented field integer value
CustomerName: varchar
EngineNo: Integer
ChasisNo: Integer
FromDate: Date
Solution –
);
4. As an UnderWriter, write SQL query to insert the insurance details into the above created
table.
Solution –
VALUES
('ABC1234', '4-wheeler', 'Alice Johnson', 123456, 654321, '9876543210', 'Full Insurance', 5000.00,
'2024-01-01', DATE_ADD('2024-01-01', INTERVAL 365 DAY), 1),
('XYZ5678', '2-wheeler', 'Bob Smith', 223456, 754321, '8765432109', 'ThirdParty', 2000.00, '2024-
01-01', DATE_ADD('2024-01-01', INTERVAL 365 DAY), 1),
('LMN4321', '4-wheeler', 'Charlie Brown', 323456, 854321, '7654321098', 'Full Insurance', 6000.00,
'2024-01-10', DATE_ADD('2024-01-10', INTERVAL 365 DAY), 2),
5. Write a query in SQL to filter the below details by using the PolicyNo:
CustomerName: varchar
EngineNo: Integer
ChasisNo: Integer
FromDate: Date
SELECT
VehicleNo,
VehicleType,
CustomerName,
EngineNo,
ChasisNo,
PhoneNo,
Type,
PremiumAmt,
FromDate,
ToDate,
UnderwriterId
FROM
StarProtect.Insurance
WHERE
PolicyNo = @PolicyNo; -- Replace @PolicyNo with the actual PolicyNo you want to filter by
CustomerName: varchar
EngineNo: Integer
ChasisNo: Integer
Solution –
SELECT
UnderwriterId,
COUNT(PolicyNo) AS NumberOfVehiclesRegistered
FROM
StarProtect.Insurance
GROUP BY
UnderwriterId;
7. Write a query in SQL to find the insurance details of vehicle whose to date field is a past
date i.e. insurance policy has expired.
Solution –
SELECT
PolicyNo,
VehicleNo,
VehicleType,
CustomerName,
EngineNo,
ChasisNo,
PhoneNo,
Type,
PremiumAmt,
FromDate,
ToDate,
UnderwriterId
FROM
StarProtect.Insurance
WHERE
ToDate < CURDATE(); -- Checks if ToDate is less than the current date
Solution –