列排序不按预期工作

时间:2016-02-15 11:34:47

标签: sql sorting reporting-services textbox sql-order-by

我有一个报告,其中包含姓名参数 - 姓氏姓氏

当选择所有名称时,它应相应地在图表和表格中显示值

在我的图表中,名称按排序顺序显示,但在我的表格中,它们看起来并不相同。

我使用了' ORDERBY forename'在我的SQL查询和tablix属性中的forename排序。

Query:

SELECT DISTINCT 
Code, Forename, Forename + ' ' + Surname AS Name, Age, Year, Area, Type, StartTime, EndTime
FROM Table
WHERE        (Age IN (@Age)) AND (Type IN (@Type)) AND (Year = @Year)
GROUP BY Code, Forename, Surname, Age, Year, Area, Type, StartTime, EndTime
ORDER BY Forename

O / P:

Code    Forename   Name   Age   Year    Area    Type    StartTime   EndTime
 SHEEA1 Alyson  Alyson Sheen    1416    2015    Eng+Maths   GCSE    1899-12-30 09:00    1899-12-30 10:30
 SHEEA1 Alyson  Alyson Sheen    1416    2015    Eng+Maths   GCSE    1899-12-30 13:15    1899-12-30 14:45
 SHEEA1 Alyson  Alyson Sheen    1416    2015    Eng+Maths   GCSE    1899-12-30 15:00    1899-12-30 16:30
 DIXOD1 Daniel  Daniel Dixon    1416    2015    Eng+Maths   GCSE    1899-12-30 10:45    1899-12-30 12:15
 DIXOD1 Daniel  Daniel Dixon    1416    2015    Eng+Maths   GCSE    1899-12-30 13:15    1899-12-30 14:45
 KAYEJ1 Jemma   Jemma Kaye  1416    2015    Eng+Maths   GCSE    1899-12-30 09:00    1899-12-30 10:30
 AMOOJ1 Josephine   Josephine Amoo  1416    2015    Eng+Maths   GCSE    1899-12-30 15:15    1899-12-30 16:45
 AMOOJ1 Josephine   Josephine Amoo  1416    2015    Eng+Maths   GCSE    1899-12-30 13:30    1899-12-30 15:00
 LEEK2  Katy    Katy Lee    1416    2015    Eng+Maths   GCSE    1899-12-30 09:00    1899-12-30 10:30
 LEEK2  Katy    Katy Lee    1416    2015    Eng+Maths   GCSE    1899-12-30 11:00    1899-12-30 12:30
 LEEK2  Katy    Katy Lee    1416    2015    Eng+Maths   GCSE    1899-12-30 13:30    1899-12-30 15:00
 NSUBL1 Lawrence    Lawrence Nsubuga    1416    2015 Eng+Maths GCSE 1899-12-30 13:15    1899-12-30 15:00
 NSUBL1 Lawrence    Lawrence Nsubuga    1416    2015    Eng+Maths   GCSE    1899-12-30 09:00    1899-12-30 10:30
 NSUBL1 Lawrence    Lawrence Nsubuga    1416    2015 Eng+Maths  GCSE    1899-12-30 15:00    1899-12-30 16:30
 GOODN1 Nicola  Nicola Goodman  1416    2015    Eng+Maths   GCSE    1899-12-30 09:00    1899-12-30 10:30

我该如何纠正?

1 个答案:

答案 0 :(得分:0)

Tablix的行组具有各自独立的排序属性集,这些属性优先于整个Tablix的排序属性。右键单击Row Group以打开它的Properties,并选中Sorting选项。

如果您在人员代码值的Tablix中创建了一个行组,则“代码”列将成为该组的默认排序。通过更改组的属性,您仍然可以按代码分组,但按名称排序。

Group Sorting Properties screenshot