Last post Mar 15, 2016 01:56 AM by Weibo Zhang
Mar 12, 2016 08:37 PM|ali lashari|LINK
Hello Every One...
I have a following query in Visual Studio 2012 but have problem and didn't work
"SELECT (SELECT SUM(Received) FROM Land_Revenue) - (SELECT SUM(amount) FROM Land_Expenses)"
Exception generated As Unspecified Error
Mar 12, 2016 09:31 PM|PawanPal|LINK
Try running both the queries separately if they are running fine.
Mar 14, 2016 06:36 AM|wmec|LINK
"SELECT (SELECT SUM(Received) FROM Land_Revenue - SELECT SUM(amount) FROM Land_Expenses) as Total_column,..."
Mar 15, 2016 01:56 AM|Weibo Zhang|LINK
Hi ali lashari,
I have found a
similar thread in MSDN, maybe it’s what you have posted there. If I’m wrong, please let me know. If so, I suggest you’d better have a look at
Besides, I have created some demos as below and tested them on my client, they all works fine. When I use ADO.NET to execute the second query command, it could also get the expected result. So, if your issue still exists, you’d better share your complete
code and the detailed error message, so that we could made a test on our my clients to help you find out the issue point.
declare @Land_Revenue table(Received int)
declare @Land_Expenses table(amount int)
insert into @Land_Revenue values(10),(20),(30),(40),(50)
insert into @Land_Expenses values(9),(18),(27),(36),(45)
SELECT (SELECT SUM(Received) FROM @Land_Revenue) - (SELECT SUM(amount) FROM @Land_Expenses)
--A second demo
SELECT (SELECT SUM([UnitPrice]) FROM [Northwind].[dbo].[Products] where [CategoryID]=1) - (SELECT SUM([UnitPrice]) FROM [Northwind].[dbo].[Products] where [CategoryID]=2)