DB2 SYNTAX

I have the following conversions in SQL and need to convert them to DB2 syntax. Can anyone lend a hand? Thx

COUNT(DISTINCT ISNULL(CONVERT(varchar(255),A.CN),'') + isnull(CONVERT(varchar(255),A.ID) , ''))
sum(CONVERT(money,B.BILL_AMNT)/CONVERT(money,100.0)),
sum(CONVERT(money,ISNULL(B.AMT_AFTR,'0'))/CONVERT(money,100.0))
earngreenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

momi_sabagCommented:
COUNT(DISTINCT coalesce(varchar(A.CN),'') || coalesce(varchar(A.ID) , ''))

sum(dec(B.BILL_AMNT)/dec(100.0)),

sum(dec(coaelsce(B.AMT_AFTR,0))/dec(100.0))
0
k_murli_krishnaCommented:
In DB2:

COUNT(DISTINCT COALESCE(CAST(A.CN AS varchar(255)),'') + COALESCE(CAST(A.ID AS varchar(255)),'')

To convert these 2, apart from whatever is already illustrated above:

sum(CAST(money,B.BILL_AMNT)/CONVERT(money,100.0)),
sum(CONVERT(money,ISNULL(B.AMT_AFTR,'0'))/CONVERT(money,100.0))

Refer CURRENCY function in DB2 for the money data type:
http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.sqlref/db2z_udf_currency.htm

0
earngreenAuthor Commented:
I am getting the following error on COUNT(DISTINCT COALESCE(CAST(A.CN AS varchar(255)),'') + COALESCE(CAST(A.ID AS varchar(255)),'')

A value with data type "SYSIBM.INTEGER" cannot be CAST to type "SYSIBM.VARCHAR".

The following seemed to work if I take the coaelsce out.

sum(dec(B.BILL_AMNT)/dec(100.0)),

sum(dec(coaelsce(B.AMT_AFTR,0))/dec(100.0))
0
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

k_murli_krishnaCommented:
Try COUNT(DISTINCT COALESCE(CHAR(A.CN),'') + COALESCE(CHAR(A.ID),''))
0
earngreenAuthor Commented:
I get the following

The data type of an operand of an arithmetic function or operation "+" is not numeric.
0
momi_sabagCommented:
COUNT(DISTINCT COALESCE(CHAR(A.CN),'') || COALESCE(CHAR(A.ID),''))
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
earngreenAuthor Commented:
That  worked. Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.