Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-11-14
1
Medium Priority
?
444 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 2000 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

670 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