Solved

SQL 2005 View.  How to calculate a view expression column with more details

Posted on 2007-11-14
1
397 Views
Last Modified: 2008-02-01
I am trying to further narrow down an expression in a view.  Below is the expression:

dbo.Payments.AmountPaid - (dbo.InvoiceDetails.Usage * dbo.InvoiceDetails.Price + ISNULL((dbo.InvoiceDetails.TRate / 100) * (dbo.InvoiceDetails.Price * dbo.InvoiceDetails.Usage), 0))

I want to take the above expression and make the outcome 0 if AmountPaid is 0.
Only when there is an amoutpaid is when I want to see the value else 0.

Thanks
0
Comment
Question by:mphillip85
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20282441
case when dbo.Payments.AmountPaid  = 0 then 0 else dbo.Payments.AmountPaid - (dbo.InvoiceDetails.Usage * dbo.InvoiceDetails.Price + ISNULL((dbo.InvoiceDetails.TRate / 100) * (dbo.InvoiceDetails.Price * dbo.InvoiceDetails.Usage), 0)) end
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now