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
Question
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
Solution
To achieve this, you can use the SQL query below to select and display all the details of bills with a payment_date
in the year 2018, sorted by payable_amount
in descending order.
SELECT *
FROM bills
WHERE YEAR(payment_date) = 2018
ORDER BY payable_amount DESC;
Explanation:
- *SELECT : This command selects all columns from the
bills
table. - FROM bills: This specifies the table from which to retrieve the data.
- WHERE YEAR(payment_date) = 2018: This condition filters the results to only include bills where the
payment_date
falls in the year 2018. - ORDER BY payable_amount DESC: This sorts the filtered results by the
payable_amount
in descending order, meaning higher amounts will appear first.
Make sure to run this query in your SQL environment to view the results.
Similar Questions
Write a query to display the details of the 'bill' whose payment is not completed. Display the records in ascending order based on due_date.
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 the total_units, payable_amount and fine_amount of bill table. Display the records in descending order based on their total_units
Write a query to display travel_card_id, entry_time and exit_time from the travel_payment.Display the records in ascending order based on the entry_time.
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.