Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The query I have keeps giving me issues and doesn't populate, please help correct it so It populates. I need help editing/writing an sql query
The query I have keeps giving me issues and doesn't populate, please help correct it so It populates.
I need help editing/writing an sql query with these tables for a tabular report from AdventureWorks2019:
Production.ProductCategory
Production.ProductSubcategory
Production.Product Sales.SalesOrderHeader
Sales.SalesOrderDetails
The query I have keeps giving me issues and doesn't populate, please help correct it so It populates.
SELECT YEAR(SalesOrderHeader.OrderDate) AS OrderYear, ProductCategory.Name AS Category, ProductSubcategory.Name AS Subcategory, Product.Name AS Product, SUM(SalesOrderDetails.LineTotal) AS Sales FROM Sales.SalesOrderHeader INNER JOIN SalesOrderDetails ON SalesOrderHeader.SalesOrderID = SalesOrderDetails.SalesOrderID INNER JOIN Product ON SalesOrderDetails.ProductID = Product.ProductID INNER JOIN ProductSubcategory ON Product.ProductSubcategoryID = ProductSubcategory.ProductSubcategoryID INNER JOIN ProductCategory ON ProductSubcategory.ProductCategoryID = ProductCategory.ProductCategoryID GROUP BY YEAR(SalesOrderHeader.OrderDate), ProductCategory.Name, ProductSubcategory.Name, Product.Name, OrderYear ORDER BY OrderYear DESC, Category ASC, Subcategory ASC, Sales DESC; You work for Adventure Works, a bicycle and accessories company. Your boss would like to have a report for "Sales by Year". They want a pdf as a final product that will print out nicely for the attendees of an upcoming meeting and yearly sales review. Further discussion with your boss of the report leads to the following list of requirements: - Page Header: with Report Title and author name - Page Footer: with execution time and page numbering - Static Headers / Footers - OrderYear - descending - Category - ascending - Subcategory - ascending - Sales - descending - Grand Total - Color Coding - Landscape Print Format Considering this, you decide to create a tabular report using the following tables: - ProductCategory - ProductSubcategory - Product - SalesOrderHeader - SalesOrderDetails (Sales is "LineTotal" from SalesOrderDetails) (Your resulting pdf report should resemble:) Sales By Year Author: Mindy Knowles 8/29/2022 9:28:09 PM Page 1 of 35 Example middle page: Example last page: Sales By Year Author: Mindy Knowles You work for Adventure Works, a bicycle and accessories company. Your boss would also like to have a report in matrix format, showing "Category Sales by Year" in an excel file for use in their presentation to the meeting attendees. Using the same tables from the first report, you build a concise matrix report. Category Sales By Year Matrix Authori Mindy Knowiles (Total is "LineTotal" from SalesOrderDetails)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