Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tsql Visual Studio报告中的聚合未显示_Tsql_Visual Studio 2008_Reporting Services_Aggregate Functions - Fatal编程技术网

Tsql Visual Studio报告中的聚合未显示

Tsql Visual Studio报告中的聚合未显示,tsql,visual-studio-2008,reporting-services,aggregate-functions,Tsql,Visual Studio 2008,Reporting Services,Aggregate Functions,我正在尝试创建一个合并两个数据集的报表。它接受(1)一个日期范围内特定客户的一系列订单,并将其与(标题)和(2)发货方法结合,然后是下订单和发送订单之间的平均时间间隔 下面的屏幕截图显示,在SQL Server中,查询可以完美地工作。然而,当我在VisualStudio2008中运行这个完全相同的查询来为此创建报告时,平均周转时间的实际值是空的 据我所知,在SQL Server中,无论我给出什么参数,查询都能完美地工作。我就是不明白为什么报告中的平均周转时间总是空白的 我正在运行的查询是: DE

我正在尝试创建一个合并两个数据集的报表。它接受(1)一个日期范围内特定客户的一系列订单,并将其与(标题)和(2)发货方法结合,然后是下订单和发送订单之间的平均时间间隔

下面的屏幕截图显示,在SQL Server中,查询可以完美地工作。然而,当我在VisualStudio2008中运行这个完全相同的查询来为此创建报告时,平均周转时间的实际值是空的

据我所知,在SQL Server中,无论我给出什么参数,查询都能完美地工作。我就是不明白为什么报告中的平均周转时间总是空白的

我正在运行的查询是:

DECLARE @turnaroundInfo TABLE
(
    [Owner Reference] VARCHAR(48),
    [Project] VARCHAR(48),
    [Carrier Type] VARCHAR(48),
    [Created Date] DATETIME,
    [Shipped Date] DATETIME,
    [Turnaround Time (hours)] INT
)
INSERT INTO @turnaroundInfo
SELECT orders.ownerReference AS [Owner Reference], p.name AS [Project], types.name AS [Carrier Type], orders.createdSysDateTime AS [Created Date], shipments.shippedDate AS [Shipped Date],  DATEDIFF(HOUR,             orders.createdSysDateTime, shipments.shippedDate) AS [Turnaround Time (hours)]
FROM datex_footprint.Orders orders
    INNER JOIN datex_footprint.Projects p ON orders.projectId = p.id
    INNER JOIN datex_footprint.CarrierServiceTypes types ON orders.preferredCarrierServiceTypeId = types.id
    INNER JOIN datex_footprint.OrderLines lines ON orders.id = lines.orderId
    INNER JOIN datex_footprint.Shipments shipments ON lines.shipmentId = shipments.id
WHERE p.name IN (@project)  AND types.name IN(@carrier)

-- Get only the type and date-ranged turnaround info we want
DECLARE @orders TABLE
(
    [Owner Reference] VARCHAR(48),
    [Project] VARCHAR(48),
    [Carrier Type] VARCHAR(48),
    [Created Date] DATETIME,
    [Shipped Date] DATETIME,
    [Turnaround Time (hours)] INT
)
INSERT INTO @orders
SELECT  *
FROM @turnaroundInfo
WHERE [Turnaround Time (hours)] >= 0 AND [Created Date] BETWEEN @startDate AND @endDate
ORDER BY [Turnaround Time (hours)], [Carrier Type] ;


-- UNION the relevant turnaround infor with headers
SELECT * FROM @orders o /*  All the orders in the date range for this project and the selected carrier(s) */
UNION ALL
SELECT 'Carrier' AS [Carrier Type], 'Avg Turnaround Time' AS [Average Turnaround], NULL AS Column3, NULL AS Column4, NULL AS Colummn5, NULL AS Column6
UNION ALL
SELECT o.[Carrier Type], CAST(AVG(o.[Turnaround Time (hours)]) AS NVARCHAR(24)) AS [Average Turnaround], NULL AS Column3, NULL AS Column4, NULL AS Colummn5, NULL AS Column6
FROM @orders o
GROUP BY o.[Carrier Type];
有人知道或看到我可能遗漏了什么吗?
任何帮助都将不胜感激

它不是空的,只是可能不在您期望的列中-我可以在您的屏幕截图中看到值“24”。

我发现了我的错误所在。 关于值24的列以及标题和24值列的大小不同。在SQLServer中,它似乎并不在意,但在VisualStudio中,它看到了大小的差异,实际上从显示中删除了整个列


在我将average value列调整为VARCHAR(48)后,它再次正确显示。

注意:我不知道为什么屏幕截图会打断这句话,但它似乎不想让我修复它。该屏幕截图来自SQL Server。我试图显示我在SQL Server中得到了我所期望的结果,但是当我运行报告时,24的值是空的——尽管查询和参数完全相同。