简体   繁体   English

如何更改Crystal Reports中字段的排序顺序?

[英]How can I alter the sort order of a field within Crystal Reports?

I have built a report in Crystal which lists prices by location by product. 我在Crystal中建立了一个报告,其中按产品位置列出价格。 The products are grouped into categories. 产品分为几类。 The query is based in Microsoft SQL Server. 该查询基于Microsoft SQL Server。 The report users want the products in a customized order, which I can build into the query but is not reflected within the database/formula fields in Crystal. 报表用户希望按自定义顺序排列产品,我可以将其内置到查询中,但不会反映在Crystal的数据库/公式字段中。 What I want is [Can't post images due to being new] ... Grouped by Unit of Measurement, grouped by Product Type, listed by Product, locations across the top, prices listed for each product by location... but I need the products in order: 8,3,5,9... etc. 我想要的是[由于新商品而无法发布图片] ... ...按度量单位分组,按产品类型分组,按产品列出,顶部位置,按位置列出每种产品的价格...但是我需要的产品顺序为:8、3、5、9 ...等。

How do I get it to sort by this custom order? 如何获得按此自定义订单排序的信息? In query form, I just hard-coded an order to the products (temporarily, this will only be 20 items or so), but that order doesn't carry over into the report because I can't sort the field by another field. 在查询表单中,我只是对产品的订单进行了硬编码(临时,这只能是20个左右),但是该订单不会延续到报表中,因为我无法按另一个字段对字段进行排序。 Help? 救命?

The query that follows does not have the sorting. 后面的查询没有排序。 I sorted it by using CASE WHEN ProductID = X THEN Y and added an ORDER BY at the end. 我使用CASE WHEN ProductID = X THEN Y对其进行了排序,并在末尾添加了ORDER BY。 This worked within the SQL server but not on Crystal. 这在SQL Server中有效,但在Crystal上无效。

DECLARE @Customer AS nvarchar(10)
SET @Customer ='99999'       'This is changed to {Customer} form on Crystal.

SELECT CustData.Name + ' (' + CustData.CustomerID + ')' AS Customer
,CASE WHEN LocatInv.LocReg1 = '' THEN 101 ELSE 0 END AS LocReg
,ISNULL(Syc.Description,'') Type
,LocatInv.Description + ' (' + RIGHT(LocatInv.LocationID, 2) + ')'
 AS Location
,ProductF.Description + ' (' + ProductF.ProductID + ')' AS Product
,PricingI.Price1 AS Price, ProductF.Unit

FROM LocatInv WITH (NOLOCK)

INNER JOIN LocatProd ON LocatInv.LocationID = LocatProd.LocationID
INNER JOIN ProductF ON ProductF.ProductID = LocatProd.ProductID
INNER JOIN PricingI ON PricingI.LocationID = LocatProd.LocationID
 AND PricingI.ProductID = LocatProd.ProductID
INNER JOIN CustData ON CustData.PriceListID = PricingI.PriceListID
LEFT JOIN (select DISTINCT Syclass.ItemID, Syclass.Description
 FROM Syclass WITH (NOLOCK) WHERE Syclass.ClassID='CLASSPR3') Syc
ON ProductF.ProductClass3 = Syc.ItemID
WHERE LocatProd.Active = 'A' AND CustData.CustomerID=@Customer
 AND ProductF.UserField1 = 'A'

Actually a picture would help to answer..but will try to answer 实际上,图片可以帮助回答..但会尝试回答

If you have grouped according to product then you go to the change group and in that go to tab custom... There you mention the order how you want to display 如果您已按产品分组,则转到更改组,然后转到“自定义”选项卡...在那里提到要显示的顺序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM