Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT within IF or within CASE ...WHEN ...THEN

Status
Not open for further replies.

billiard

Programmer
Jul 15, 2015
8
ZW
I am writing a SELECT script in Pervasive 10.3 I need the logic to have a SELECT within an IF or CASE tried the statements below but that does not seem to work. Once I do any of the two below my SELECT select fewer rows.

CASE WHEN a.Item = 1 THEN ( SELECT ISNULL(SUM(o.Amount),0) FROM Debtors AS o WHERE RTRIM(LTRIM(o.CScode)) = RTRIM(LTRIM(a.CustomerCode)))
WHEN a.Item = 0 THEN (a.DBbalance) END

or like

IF ( a.Item = 0, (a.DBbalance) , ( SELECT ISNULL(SUM(o.Amount),0) FROM Debtors AS o WHERE RTRIM(LTRIM(o.CScode)) = RTRIM(LTRIM(a.CustomerCode))) )


Please help !!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top