Microsoft SQL Server 2000 Reporting Services Introduction (5)

zhaozj2021-02-16  55

Microsoft SQL Server 2000 Reporting Services Introduction (5)

[Abstract] This article mainly introduces how to integrate the REPORT Designer and modify the RDL file to quickly and flexible

The report   步 饬?? LT; / span> Matrix format and Toggle function

[Keyword] Reporting Services, .NET Framework, RDL file, Matrix format, Toggle function

n how to implement Matrix

The image above is an example provided in Reporting Services. Vertical to a company's product category and subcategory, lateral direction for years and quarter, this display mode can be used in many reports, such as general group companies will display out in portrait All molecular companies and departments. The following is an angle of the RDL file to analyze how this example is implemented. First, let's take a look at the query statement.

AdventureWorks // Specify the data source name

Select ProductCategory.name asprodcate, // Product Category Productsubcategory.name As Subcat, // Product Subcategory

DatePart (YY, SalesOrdeerHeader.orderdate) as Orderyear, // Year

'Q' Datename (QQ, SalesOrdeerHeader.orderdate) as Orderqtr, // Quarter SUM (SalesOrderDetail.Unitprice * SalesOrderDetail.orderqty) AS Sales // Sales Data

From productSubcategory Inner Join

....................

WHERE (SalesOrderHeader.orderdate Between '1/1/2002' and '12 / 31/2003 ') // Time range

/ / The Group by GROUP BY guarantees the hierarchical relationship between data

GROUP BY

DatePart (YY, SalesOrdeerHeader.orderdate), Productsubcategory.Name, Productsubcategory.Name, 'Q' Datename (QQ,

SalesOrderHeader.orderdate), Productsubcategory.ProductSubcategoryId

Let's take a look at how the RDL is hidden under the year.

// This dynamic column name is OrderQtr

= Fields! Orderqtr.Value

// This section implements the hidden quarterly column, and the Toggle relationship with ORDERYEAR, only three lines of code realize a complex data hierarchical relationship, which shows the power of Reporting Services.

ORDERYEAR

True

Similarly, the product category and product subcategory are also established, although this function can be easily implemented through the .NET development environment, but can save a lot of time if you can perform the RDL files. Let's take a look at how the report shows sales data.