Solved

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

Posted on 2007-11-14
1
442 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 143

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

622 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