Skip to Content
author's profile photo Former Member
Former Member

Convert alphanum UDF to number in query

Hi,

I'm including a SUM on a UDF in a query I've created. The UDF has to be set up as alphanumeric since it would not be a round number (ex. 495.50). I'm getting an error on the SUM portion and thinking I need to convert the UDF to number field in the query - how would I do this?

Thank you!

Heather

Here is the query:

SELECT T0.ContractID, T0.CstmrName, T1.U_Site, T2.ItmsGrpNam], T1.StartDate, T1.EndDate], T1.U_Rentype, T1.U_Freq, T1.U_RRate], T1.U_User], T1.U_RenStatus] FROM OCTR T0 INNER JOIN CTR1 T1 ON T0.ContractID = T1.ContractID INNER JOIN OITB T2 ON T1.ItemGroup = T2.ItmsGrpCod WHERE T0.Status ='A'

UNION ALL

SELECT '', '', '', '', NULL, NULL, 'Total', '', SUM(T1.U_RRate), '', ''

FROM OCTR T0 INNER JOIN CTR1 T1 ON T0.ContractID = T1.ContractID INNER JOIN OITB T2 ON T1.ItemGroup = T2.ItmsGrpCod

WHERE T0.Status ='A'

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on May 04, 2011 at 08:32 PM

    Hi Heather,

    Try this

    SELECT T0.ContractID, T0.CstmrName, T1.U_Site, T2.[ItmsGrpNam], T1.StartDate, T1.[EndDate], T1.U_Rentype, T1.U_Freq, CAST(T1.[U_RRate] as INT), T1.[U_User], T1.[U_RenStatus] FROM OCTR T0 INNER JOIN CTR1 T1 ON T0.ContractID = T1.ContractID INNER JOIN OITB T2 ON T1.ItemGroup = T2.ItmsGrpCod WHERE T0.Status ='A' 
    UNION ALL
    SELECT '', '', '', '', NULL, NULL, 'Total', '', SUM(CAST(T1.U_RRate as Int)), '', ''
    FROM OCTR T0 INNER JOIN CTR1 T1 ON T0.ContractID = T1.ContractID INNER JOIN OITB T2 ON T1.ItemGroup = T2.ItmsGrpCod 
    WHERE T0.Status ='A'

    OR

    SELECT T0.ContractID, T0.CstmrName, T1.U_Site, T2.[ItmsGrpNam], T1.StartDate, T1.[EndDate], T1.U_Rentype, T1.U_Freq, CONVERT(INT, T1.[U_RRate]), T1.[U_User], T1.[U_RenStatus] FROM OCTR T0 INNER JOIN CTR1 T1 ON T0.ContractID = T1.ContractID INNER JOIN OITB T2 ON T1.ItemGroup = T2.ItmsGrpCod WHERE T0.Status ='A' 
    UNION ALL
    SELECT '', '', '', '', NULL, NULL, 'Total', '', SUM(CONVERT(INT,T1.U_RRate)), '', ''
    FROM OCTR T0 INNER JOIN CTR1 T1 ON T0.ContractID = T1.ContractID INNER JOIN OITB T2 ON T1.ItemGroup = T2.ItmsGrpCod 
    WHERE T0.Status ='A'

    Regards,

    Bala

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.