Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
angela_g
Starting Member
17 Posts |
Posted - 2014-01-24 : 09:36:53
|
I am trying to produce a report in Application express. I want to find records where there is a difference between 2 columns eg Debt_amount - billed_amountwhere debt >billed amountI only want to see records where the debt is more than the amount billed |
|
sqlsaga
Yak Posting Veteran
93 Posts |
Posted - 2014-01-24 : 11:33:35
|
[code]DECLARE @Accounts TABLE(AccountID INT,DebtAmt INT,BilledAmt INT)INSERT INTO @Accounts VALUES(1, 10, 25)INSERT INTO @Accounts VALUES(2, 50, 4)INSERT INTO @Accounts VALUES(3, 10, 10)INSERT INTO @Accounts VALUES(4, 100, 75)INSERT INTO @Accounts VALUES(5, 40, 30)INSERT INTO @Accounts VALUES(6, 20, 25)SELECT AccountID, [DebtAmt] - [BilledAmt] AS [RemainingAmt]FROM @AccountsWHERE DebtAmt > BilledAmt[/code]Good Luck :)Visit www.sqlsaga.com for more SQL and BI related snippets and how to'sVisit www.sqlsaga.com for more t-sql snippets and BI related how to's. |
 |
|
|
|
|
|
|