Hi All,
Can anybody please tell me if a query such as this (Valid in MS Access)
can work in SQL Server:
SELECT Description, Sum(Total) FROM (
SELECT Description, Total FROM Table_A
UNION ALL
SELECT Description, Total FROM Table_B
UNION ALL
SELECT Description, Total FROM Table_C
)
GROUP BY Description
The group of unions work by themselves, but when I try to nest an outer query to do some a Summation(), I have syntax errors.
Any insight would be greatly appreciated. Thank you.You must supply an alias for your subquery:
SELECT Description,
Sum(Total)
FROM (SELECT Description,
Total
FROM Table_A
UNION ALL
SELECT Description,
Total
FROM Table_B
UNION ALL
SELECT Description,
Total
FROM Table_C) AS SUBQUERY
GROUP BY Description|||Thanks BlindMan, u da man.
:)
Showing posts with label total. Show all posts
Showing posts with label total. Show all posts
Monday, March 19, 2012
Monday, February 20, 2012
Need to sum columns
I need to create a view (I believe) that will take a column named
'accountbalance' for a group of records, and total (sum) up those entries...
can someone point me to a tutorial to learn how to do this? THanks!
Never mind.. I found a reference. thanks tho
'accountbalance' for a group of records, and total (sum) up those entries...
can someone point me to a tutorial to learn how to do this? THanks!
Never mind.. I found a reference. thanks tho
Need to sum columns
I need to create a view (I believe) that will take a column named
'accountbalance' for a group of records, and total (sum) up those entries...
can someone point me to a tutorial to learn how to do this? THanks!Never mind.. I found a reference. thanks tho
'accountbalance' for a group of records, and total (sum) up those entries...
can someone point me to a tutorial to learn how to do this? THanks!Never mind.. I found a reference. thanks tho
Need to sum columns
I need to create a view (I believe) that will take a column named
'accountbalance' for a group of records, and total (sum) up those entries...
can someone point me to a tutorial to learn how to do this? THanks!Never mind.. I found a reference. thanks tho
'accountbalance' for a group of records, and total (sum) up those entries...
can someone point me to a tutorial to learn how to do this? THanks!Never mind.. I found a reference. thanks tho
Subscribe to:
Posts (Atom)