Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Return tow values from different tables with no common key

$
0
0

I hvae 2 tables(tblSalary and tblDailyExpenses) in tblSalary I have a column PaydAmount that keeps the salary amount paid per employee, and in tblDailyExpenses I have a column Amount that keeps the paid amount per invoice,
I want to return the total paid salary(PaydAmount) and the total amount of paid expenses(Amount) in a month.
I have tried this query.

Select ((select SUM(PaydAmount) from tblSalary where tblSalary.Month=4) AS PaydSalary,
(Select SUM(Amount) from tblDailyExpenses where tblDailyExpenses.Month=4) AS PaydExpenses)

I am using Sqlserver Compact edition


where I want to return it in a datagridview as shown below

#| Type                |  Amount
-------------------------
1| Daily Expenses |  1200
-------------------------
2| Salary Paid      |  7800


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>