Write a SELECT statement that returns one row for each general
ledger account number that contains three columns: The
account_description column from the General_Ledger_Accounts table
The count of the items in the Invoice_Line_Items table that have
the same account_number. The sum of the line_item_amount columns in
the Invoice_Line_Items table that have the same
account_number
Return only those rows where the count of line items is greater
than 1. This should return 10 rows.
Group the result set by the account_description column. Sort the
result set in descending sequence by the sum of the line item
amounts.
SQL QUERY:
SELECT gen_la.account_description, count(*), sum(inoivce_li.line_item_amount)
FROM general_ledger_accounts glen_a
INNER JOIN invoice_line_items invoice_li ON invoice_li.account_number = gen_la.account_number
GROUP BY gen_la.account_description
HAVING count(*) > 1
ORDER BY SUM(invoice_li.line_item_amount) DESC
Let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions. Thank You! ===========================================================================
Get Answers For Free
Most questions answered within 1 hours.