locked
Converting DB2 to SQL query RRS feed

  • Question

  • Hi ,

    Below is my DB2 qery, plz help me to convert into SQL,

    Select

    COUNT(DISTINCT(S)) AS Inv 

    From Table

    Regards,

    Palani


    Palani

    Monday, November 30, 2015 10:48 AM

Answers

  • It should work in t-sql as well

    Select 
    COUNT(DISTINCT S) AS Inv 
    
    From Table

    what happened when you tried the above?


    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    • Proposed as answer by Eric__Zhang Tuesday, December 1, 2015 5:48 AM
    • Marked as answer by Eric__Zhang Wednesday, December 9, 2015 7:29 AM
    Monday, November 30, 2015 10:53 AM
  • Hi,

    Try

    Select

    COUNT(DISTINCT S) AS Inv

    From Table

    Hope it helps.

    Antonio Cesar

    • Marked as answer by Eric__Zhang Wednesday, December 9, 2015 7:29 AM
    Monday, November 30, 2015 10:59 AM
  • Hi Friends,

    Thank you. I got solution.

    Regards,

    Palani


    Palani

    • Marked as answer by Palani_M Tuesday, December 8, 2015 7:29 AM
    Tuesday, December 8, 2015 7:29 AM

All replies

  • It should work in t-sql as well

    Select 
    COUNT(DISTINCT S) AS Inv 
    
    From Table

    what happened when you tried the above?


    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    • Proposed as answer by Eric__Zhang Tuesday, December 1, 2015 5:48 AM
    • Marked as answer by Eric__Zhang Wednesday, December 9, 2015 7:29 AM
    Monday, November 30, 2015 10:53 AM
  • Hi Palani, this is valid syntax in T-SQL. Are you getting an error somewhere?

    Thanks,
    Sam Lester (MSFT)


    http://blogs.msdn.com/b/samlester

    This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click "Mark as Answer" and "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread.

    Monday, November 30, 2015 10:54 AM
  • Hi,

    Try

    Select

    COUNT(DISTINCT S) AS Inv

    From Table

    Hope it helps.

    Antonio Cesar

    • Marked as answer by Eric__Zhang Wednesday, December 9, 2015 7:29 AM
    Monday, November 30, 2015 10:59 AM
  • Hi Friends,

    Thank you. I got solution.

    Regards,

    Palani


    Palani

    • Marked as answer by Palani_M Tuesday, December 8, 2015 7:29 AM
    Tuesday, December 8, 2015 7:29 AM