Write a query to display the total_units, payable_amount and fine_amount of bill table. Display the records in descending order based on their total_units
Question
Write a query to display the total_units, payable_amount and fine_amount of bill table.
Display the records in descending order based on their total_units.
Solution
To achieve the desired output from the bill
table, you can use the following SQL query:
SELECT
total_units,
payable_amount,
fine_amount
FROM
bill
ORDER BY
total_units DESC;
Explanation:
-
SELECT Clause: This part specifies the columns you want to retrieve from the
bill
table, which aretotal_units
,payable_amount
, andfine_amount
. -
FROM Clause: Indicates the table from which the data is fetched, here it is the
bill
table. -
ORDER BY Clause: This orders the records by
total_units
in descending order (DESC
), so that the records with the highest total units appear first.
This query will provide a clear view of the specified columns sorted by the number of units in descending order.
Similar Questions
Write a query to display the details of all the bills whose 'total_units' greater than 10000, sorted by total_units in descending orde
Write a query to display all the details of all the 'bills' whose payment_date is on the year 2018, sorted by payable_amount in descending order
Write a query to display the total_units and payable_amount of the particular meter number 'SG934826
Write a query to display the second minimum fine_amount from bill table. Give an alias name to the second minimum fine amount as 'second_min_fine_amount'.
Write a query to display the number of bills having fine_amount. Give an alias name as 'count_of_bills_with_fine'.
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.