MSSQL Server Reporting Services: The Authoring Phase: Overview Part I - Page 6February 26, 2004 Creating the QueryLet's say, for purposes of our session in this article, that organizational information consumers are requesting information about the products which our organization sells. One requirement is for a simple list of products by category and subcategory. We will provide the SQL that underpins the report, and then take a look at some of the cosmetics. We will look at other ways to generate the datasets later, so if you are not an SQL expert, just bear with me for now. 1. Type (or cut and paste) the following basic SQL into the Query pane of the Report Designer.
-- RS002 Basic Practice Example Query
SELECT
T1.Name AS 'Category',
T2.Name AS 'SubCategory',
T3.Name AS 'Product',
T3.ListPrice AS 'List Price'
FROM
ProductCategory T1
INNER JOIN
ProductSubCategory T2 ON T1.ProductCategoryID =
T2.ProductCategoryID
INNER JOIN
Product T3 ON T2.ProductSubCategoryID =
T3.ProductSubCategoryID;
The Query pane appears as shown in Illustration 12.
Click for larger image 2. Click the Run icon in the toolbar, shown in Illustration 13, to execute the query.
The dataset appears in the Results pane, below the query, as partially shown in Illustration 14.
We have now defined and tested a simple SQL query. Let's proceed with the next step of the Authoring process, and design the Layout of the report. |