I am generating a report from 3 tables respectively Income, Expence and Transactions.
table structure is as below:
Income:
Hi I am developing an application in VS 2010, C# and SQLCe database.
I am generating a report from 3 tables respectively Income, Expence and Transactions.
table structure is as below:
Income:

Expence:

Transactions:

For this I wrote query
Codeselect t.tDate as [Date], t.tDescription as [Detail],e.eAmount as [Debit],
Codei.iAmount as [Credit], t.balance as [Balance] from Transactions t
C#inner join Expence e on t.pid=e.pid join Income i on t.pid=i.pid where t.pid='11'Code
But when I run this query I am just getting
I want that my result should be like a bank statement as below.

As per my understanding query is not right.
How can we write query to get result like this?


pradeep kumar72 reputationPosted Feb 13, 2014, 9:12 PM EST
CREATE TABLE #INCOME
(
IncomeId INT IDENTITY(1,1),
InCome MONEY
)
CREATE TABLE #Expense
(
ExpenseId INT IDENTITY(1,1),
IncomeId INT,
Expense MONEY
)
INSERT INTO #INCOME(InCome)
VALUES (10000)
DECLARE @IncomeId INT
SET @IncomeId= IDENT_CURRENT('#INCOME')
INSERT INTO #Expense(IncomeId,Expense)
VALUES (@IncomeId,2000)
SELECT
EX.Expense,INC.IncomeId
FROM #Expense EX
INNER JOIN #INCOME INC ON INC.IncomeId=EX.IncomeId
DROP TABLE #Expense
DROP TABLE #INCOME
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 14, 2014, 1:47 AM EST
hi,
Question is not too much clear
can you please share output that you want?
Ashok KaraleRank #1,902 · 777 reputationPosted Feb 14, 2014, 8:55 PM EST