Conditional Select Statment Query


I am using attached query it is working fine.
But now as per my requirement i need some changes in this query.
Rs.Open "Select City,SallNo,Amount,WtDate,Customer,Name,Total,Mode from CityRegion where Name = '" & Text1(11).text & "' and GroupName = 'UAE' and IDTNo = 0 order by SallNo", con, adOpenKeyset, adLockOptimistic

Open in new window


i am getting following result from query.
SYDNEY, 4001, 1000, 07-01-12, SAM, MICHEAL, 1200, CREDIT
SYDNEY, 4002, 1100, 07-01-12, SAM, MICHEAL, 1400, CASH

My desired result should be like this
SYDNEY, 4001, 1000, 07-01-12, SAM, MICHEAL, 1200, CREDIT
SYDNEY, 4002, 1100, 07-01-12, SAM, MICHEAL,       0, CASH

if mode is "CASH"  then Total should be display 0
how can i do that.
LVL 1
crystal_TechAsked:
Who is Participating?
 
flow01Commented:
or if there is only one value to check

CASE Mode
WHEN 'CASH'  THEN 0
ELSE Total
END


"Select City,SallNo,Amount,WtDate,Customer,Name,CASE Mode WHEN 'CASH'  THEN 0 ELSE Total END Total,Mode from CityRegion where
0
 
sindhuxyzCommented:
You can use case in select clause
Example:
SELECT CASE
            WHEN Obsolete = 'N' or InStock = 'Y'
               THEN 1
               ELSE 0
       END as Salable, *
FROM Product
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.