Create a view named "daily_readings" to display the daily hourly readings from h1 to h24 for each meter with meter number displayed.Note:1. Do not change the name of the view2. Include only 3 columns, meter_number from meter table and its corresponding reading hours(h1-h24) from the electricity_reading table.3. Use Joins. Tables involved are meter and electricity_reading3. Submit only the CREATE VIEW query.Instructions:1. Create the view successfully2. Once the view is created, check the correctness of the virtual table by displaying all the records in it.4. DO NOT submit the select query. Submit only the CREATE VIEW query.Sample Output:Created view will contain the following same data:[only few records shown here] SubmitSaveExecutePrevious Submission1
Question
Create a view named "daily_readings" to display the daily hourly readings from h1 to h24 for each meter with meter number displayed.Note:1. Do not change the name of the view2. Include only 3 columns, meter_number from meter table and its corresponding reading hours(h1-h24) from the electricity_reading table.3. Use Joins. Tables involved are meter and electricity_reading3. Submit only the CREATE VIEW query.Instructions:1. Create the view successfully2. Once the view is created, check the correctness of the virtual table by displaying all the records in it.4. DO NOT submit the select query. Submit only the CREATE VIEW query.Sample Output:Created view will contain the following same data:[only few records shown here] SubmitSaveExecutePrevious Submission1
Solution
Based on your instructions, here is the SQL query to create the view "daily_readings":
CREATE VIEW daily_readings AS
SELECT meter.meter_number, electricity_reading.h1, electricity_reading.h2, electricity_reading.h3, electricity_reading.h4, electricity_reading.h5, electricity_reading.h6, electricity_reading.h7, electricity_reading.h8, electricity_reading.h9, electricity_reading.h10, electricity_reading.h11, electricity_reading.h12, electricity_reading.h13, electricity_reading.h14, electricity_reading.h15, electricity_reading.h16, electricity_reading.h17, electricity_reading.h18, electricity_reading.h19, electricity_reading.h20, electricity_reading.h21, electricity_reading.h22, electricity_reading.h23, electricity_reading.h24
FROM meter
JOIN electricity_reading
ON meter.meter_number = electricity_reading.meter_number;
This query creates a view named "daily_readings" that displays the daily hourly readings from h1 to h24 for each meter with meter number displayed. It uses a JOIN clause to combine rows from the "meter" and "electricity_reading" tables based on their common column, "meter_number".
Similar Questions
Create a view named 'electricity_reading_details' to select all the details of the electricity_reading whose total_units per day is greater than 500 units.Note:1. Do not change the name of the view2. Include all the column present in the electricity_reading table. Select only the records with the total_units greater than 500.3. Submit only the CREATE VIEW query.Instructions:1. Create the view successfully2. Once the view is created, check the correctness of the virtual table by displaying all the records in it.3. DO NOT submit the select query. Submit only the CREATE VIEW query.Sample Output:Created view will contain the following same data:
Create a view named "all_payable_amount" to select the meter_number from meter table and its corresponding payable_amount from the bill table.Note:1. Do not change the name of the view2. Include only 2 columns, meter_number from meter table and its corresponding payable_amount from the bill table.3. Use Joins. Tables involved are meter and bill4. Submit only the CREATE VIEW query.Instructions:1. Create the view successfully2. Once the view is created, check the correctness of the virtual table by displaying all the records in it.3. DO NOT submit the select query. Submit only the CREATE VIEW query.Sample Output:Created view will contain the following same data:
Write a query to display the meter_number from the meter table which got maximum total_units during 8PM for a day in the electricity_reading.Note:1. Display only the meter_number from the meter table which got maximum total_units during 8PM for a day in the electricity_reading. ( 8PM reading will be in h20 column).2. Tables involved are meter and electricity_reading3. Compare your executed result with the sample output given below.
Write a query to display the meter_number from the meter table which got minimum total_units during 9PM for a day in the electricity_reading. Display the records in ascending order based on their meter_number.Note:1. Display only the meter_number from the meter table which got minimum total_units during 9PM. ( 9PM reading will be in h21 column).2. Tables involved are meter and electricity_reading3. Compare your executed result with the sample output given below.
Write a query to display the sum of 12th hour unit consumption from electricity_reading table. Give an alias name to the sum of 12th hour consumption as 'sum_12th_hour_consumption'.Note:1. Display only the sum of 12th hour unit consumption from electricity reading.(12th hour reading will be h12 column).2. Specify the alias name without any mistake.3. Compare your executed result with the sample output given below.Sample output:
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.