开发者

Override sort in SQL Server 2008 Report Builder 3.0?

开发者 https://www.devze.com 2023-03-04 21:17 出处:网络
I created a dataset with a SQL query in Report Builder 3.0. I did NOT specify an order by in the query, but instead used union all to stack the results in the order I wanted. The first column in this

I created a dataset with a SQL query in Report Builder 3.0. I did NOT specify an order by in the query, but instead used union all to stack the results in the order I wanted. The first column in this dataset is called Produ开发者_Python百科ct.

When I create a table in Report Builder, referencing the Product column, it for whatever reason wants to default to alphabetical sorting of this column - which I do not want.

What can I do?? Report Builder 3.0 seems pretty primitive, so if there isn't anything I can do about this annoyance than so be it.


@Catcall is absolutely right regarding the resultset being 'undefined'. However I think the reason you are seeing the results sorted by the first column is probably because you've used the Report Builder wizard to create the output table. This tends to create a bunch of nested row groups and is probably grouping first on product and thus sorting on product.

If you create a new table and leave the row as 'details' rows (it will show as an equals sign rather than a bracket / brace) then generally Report Builder will output in the order returned by the query.

HOWEVER, it is best practice to explicitly define the sortorder, I would use RANK() or similar within each query to give you a numeric SortOrder column. Then use this within Report Builder as the Sort expression.


Try to remove the sorting options in Row Groups. (Group properties / Sorting).

Next, add a new sorting in the tablix properties. https://msdn.microsoft.com/en-us/library/dd255193.aspx


I did NOT specify an order by in the query, but instead used union all to stack the results in the order I wanted.

In the absence of an explicit ORDER BY clause, the order rows will be returned is indeterminate. It can--and often does--change from one run to another as the execution environment changes. If you don't specify an ORDER BY, the query optimizer is free to return rows in the order it decides is most efficient. You can't rely on it to make the same choices every time.

Perhaps Report Builder will honor an explicit ORDER BY in the underlying query.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号