Results 1 to 3 of 3
  1. #1
    Join Date
    May 2007
    Posts
    2

    Thumbs up Unanswered: SQL Query Help needed to convert Data Format

    Hi,

    I need help for formatting my SQL Advantage SQL query while getting the Output.I have the following Column in the Database.

    Column Name Type Length
    ------------- ------- ---------
    release int 4

    Actual Data stored in the Database (Sybase 11) for the above column is:
    3030517
    3030506
    3191919
    3011921

    I would like to get the output (also NOT to consider the NULL, -1, 0 values) in the following format:
    3.3.5.17
    3.3.5.6
    3.19.19.19
    3.1.19.21

    I would like to run the query through SQL Advantage. Can any of you help me to send the exact SQL syntax how to format the data to get my required output by using case, cast etc. As I have my output query running fine, I request you to send me the exact syntax for formatting this column only.

    Note: Similar Python Script syntax available with us is : str(release / 1000000) + '.' + str(release / 10000 % 100) + '.' + str(release/ 100 % 100) + '.' + str(release % 100). Probably this might help you to understand better my requirement.

    Thanks in advance for your help.

    Regards,
    Sasi

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    select convert(varchar(2),(release/1000000))
    +'.'+convert(varchar(2),(release/10000)%100)
    +'.'+convert(varchar(2),(release/100)%100)
    +'.'+convert(varchar(2),(release)%100)
    from (select release=
    3030517 union all select
    3030506 union all select
    3191919 union all select
    3011921
    ) view1

  3. #3
    Join Date
    May 2007
    Posts
    2

    SQL Format Query Help - Thanks

    Hi Dreyer,

    I used the SQL Syntax which you have sent with minor changes to fit in my query and it is working perfectly.

    Thank you very much for your help and to be honest, you are the only one person replied among thousands of this Forum and various other groups.

    Thanks once again

    Regards,
    Sasi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •