Write a query to display details of the train_arrival_time which does not have any deviation.Display the records in ascending order based on the metro_train_id.Note:1. Display all the columns present in the travel_arrival_time table.2. Specify the condition and retrieve the correct rows in the result(condition need to be specified on deviation. If deviation is 0, then it means it does not have any deviation).3. You can compare your executed result with the sample output given below.4. Order by is mandatorySample output:
Question
Write a query to display details of the train_arrival_time which does not have any deviation.Display the records in ascending order based on the metro_train_id.Note:1. Display all the columns present in the travel_arrival_time table.2. Specify the condition and retrieve the correct rows in the result(condition need to be specified on deviation. If deviation is 0, then it means it does not have any deviation).3. You can compare your executed result with the sample output given below.4. Order by is mandatorySample output:
Solution 1
Here is the SQL query you need to write based on your requirements:
SELECT *
FROM travel_arrival_time
WHERE deviation = 0
ORDER BY metro_train_id ASC;
Let's break it down:
-
SELECT * FROM travel_arrival_time: This part of the query is asking the database to retrieve all columns from thetravel_arrival_timetable. -
WHERE deviation = 0: This is the condition you specified. It tells the database to only include records where thedeviationis 0, meaning there is no deviation. -
ORDER BY metro_train_id ASC: This part of the query sorts the resulting records in ascending order based on themetro_train_id.
This query should give you the desired output.
Solution 2
Here is the SQL query you need:
SELECT *
FROM travel_arrival_time
WHERE deviation = 0
ORDER BY metro_train_id ASC;
Let's break it down:
-
SELECT * FROM travel_arrival_time: This part of the query is asking the database to retrieve all columns from thetravel_arrival_timetable. -
WHERE deviation = 0: This is the condition that filters the results. It's saying "only give me the rows where thedeviationis 0". In other words, it's asking for the train arrival times that don't have any deviation. -
ORDER BY metro_train_id ASC: This part of the query is sorting the results in ascending order based on themetro_train_id. "ASC" stands for "ascending", which means from lowest to highest. If you wanted to sort from highest to lowest, you would use "DESC" for "descending".
Similar Questions
Create a view named 'train_details_with_deviation' to display the metro train id,position and updated time of all the trains having deviation.Note:1. Do not change the name of the view2. Include only 3 columns, id, position and updated_time from metro_train table whose train_arrival_time got deviation.3. Use subquery. Tables involved are metro_train and train_arrival_time.4. 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.
Write a query to display all details of the station whose name starts with the letter 'K'. Display the records in ascending order based on the name.Note:1. Display all the columns present in the station table.2. Specify the condition and retrieve the correct rows in the result(condition need to be specified on name column).3. You can compare your executed result with the sample output given below.4. Order by is mandatorySample output:
Write a query to display details of the travel_payment whose amount is greater than 30. Display the records in ascending order based on the entry_time.Note:1. Display all the columns present in the travel_payment table.2. Specify the condition and retrieve the correct rows in the result(condition need to be specified on amount column).3. You can compare your executed result with the sample output given below.4. Order by is mandatorySample output: [Only few records are shown here]
Create a view named 'train_details_with_deviation' to display the metro train id,position and updated time of all the trains having deviation.
Write a query to display person name,contact number and balance of all the details, who are travelled maximum number of times. If there is multiple record dipsplay the record in descending order by person name.Note:1. Display only the peron name, contact number and balance whose travelled maximum number of times.2. Order by is mandatory.3. Compare your executed result with the sample output given below.Sample output: Submit
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.