Transact SQL - Problemer med subquery
Jeg har problemer når jeg vil kører følgende:DECLARE @date AS DATETIME
DECLARE @yesterday AS DATETIME
SET @date = '2007-11-13'
SET @yesterday = dateadd(dd, -1, @date)
SELECT @date, @yesterday
WHILE @date < getdate()
BEGIN
SELECT @date,
(SELECT timestamp, sum(order_volume)
FROM f_sales_orderbook_log
WHERE timestamp = @yesterday
GROUP BY timestamp) as 'Primo',
(SELECT timestamp, sum(order_volume)
FROM f_sales_orderbook_log
WHERE timestamp = @date
GROUP BY timestamp) as 'Ultimo'
SET @date = dateadd(dd, 1, @date)
END
Den kommer med følgende fejl:
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
Hvad skal ændres? Svar der giver en anden måde og løse problemet vil også være ok.