Question
SQL Codes for the following questions. 1. Summarize expense reports (expensereport) by status. The result should contain the expense report status (erstatus) and count of
SQL Codes for the following questions.
1. Summarize expense reports (expensereport) by status. The result should contain the expense report status (erstatus) and count of expense reports. Rename computed columns with meaningful names.
2. Summarize budget items (budgetitem) by organization number (orgno). The result should contain the organization number (orgno), sum of amounts, and sum of the actual amounts. Only summarize budget items (budgetitem) with amounts greater than $1,000. Rename computed columns with meaningful names.
3. For each expense report, list expense report number (erno) , count of expense items, sum of expense amounts, and sum of approved expense amounts (expamt). Only include expense reports in the result with more than one expense item. Rename computed columns with meaningful names. Order the result by expense report number. Use the cross product or join operator style.
4. For each expense report, list expense report number (erno), count of expense items, sum of approved expense amounts, and sum of slack amounts. Compute the slack amount as the expense category limit minus the approved expense amount. Only summarize expense reports with a submitted date in September 2020. Rename computed columns with meaningful names. Order the result by expense report number (erno). Use the cross product or join operator style.
5. Summarize budget items by organization and year. The result should include the organization name (orgname), year, sum of budget item amounts (biamt), sum of actual amounts, and count of the budget items. Only include combinations of organization name (orgname) and year with more than one budget item. Rename computed columns with meaningful names. Use the cross product or join operator style.
6. For expense reports with a submitted date in 2020, summarize expense reports by status (erstatus) and submitted month in 2020. You can use the Date_Part PostgreSQL function to extract the month of a timestamp column. Only summarize pending and approved expense reports. The result should contain the status, month of the submitted date, and the sum of approved expense item amounts. Rename computed columns with meaningful names. Use the cross product or join operator style.
7. For expense reports (expensereport) with a submitted date in 2020, summarize expense reports by organization of the submitting user and submitted month in 2020. The result should contain the organization number (orgno), month of the submitted date (ersubmitdate), and count of expense reports. Only include combinations of organization number and month in the result with more than one expense report. Rename computed columns with meaningful names. Use the cross product or join operator style.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started