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

x
?
Solved

Subquery needs 0 instead of null

Posted on 2013-01-24
2
Medium Priority
?
358 Views
Last Modified: 2013-01-24
I have the following sql with a subquery.  If the subquery does not return a record I need it to return a 0. Tried to figure out something with isnull()

SELECT
            ClientId,

             (SELECT  SUM(ClientDebtXref.Balance)  FROM ClientDebtXref WHERE ClientDebtXref.ClientApplicationID = @ClientID AND DebtTypeID=7 )  HomeEquityBalance,


               CurrentMonthlyOutstandingMortagageBalance ,
             AssetLienBalance
from Assets
0
Comment
Question by:Charles Baldo
[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
2 Comments
 
LVL 39

Accepted Solution

by:
appari earned 2000 total points
ID: 38816924
try this

SELECT
            ClientId,

            isnull( (SELECT  SUM(ClientDebtXref.Balance)  FROM ClientDebtXref WHERE ClientDebtXref.ClientApplicationID = @ClientID AND DebtTypeID=7 ) ,0)  HomeEquityBalance,


               CurrentMonthlyOutstandingMortagageBalance ,
             AssetLienBalance
from Assets 

Open in new window

0
 

Author Closing Comment

by:Charles Baldo
ID: 38816929
Thanks it works
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
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…

722 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