-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDS_OverClause.rsd
48 lines (48 loc) · 1.65 KB
/
DS_OverClause.rsd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?xml version="1.0" encoding="utf-8"?>
<SharedDataSet xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/shareddatasetdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSet Name="DataSet1">
<Query>
<DataSourceReference>ShDS_AdventureWorks</DataSourceReference>
<CommandText>WITH CTE_SalesPersons AS (SELECT
SalesPersonID,
SalesOrderID,
OrderDate,
TotalDue,
AVG(TotalDue) OVER (PARTITION BY SalesPersonID) AS AvgSalesPerPerson,
RANK() OVER (PARTITION BY SalesPersonID ORDER BY TotalDue DESC) AS SalesRankByAmount
FROM
Sales.SalesOrderHeader
WHERE
SalesPersonID IS NOT NULL)
SELECT *
FROM CTE_SalesPersons
WHERE SalesRankByAmount in (1,2,3)</CommandText>
</Query>
<Fields>
<Field Name="SalesPersonID">
<DataField>SalesPersonID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="SalesOrderID">
<DataField>SalesOrderID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="OrderDate">
<DataField>OrderDate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
<Field Name="TotalDue">
<DataField>TotalDue</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="AvgSalesPerPerson">
<DataField>AvgSalesPerPerson</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="SalesRankByAmount">
<DataField>SalesRankByAmount</DataField>
<rd:TypeName>System.Int64</rd:TypeName>
</Field>
</Fields>
</DataSet>
</SharedDataSet>