Results 1 to 11 of 11

Thread: [RESOLVED] format string to number

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    Resolved [RESOLVED] format string to number

    I have this field of varchar with values 00001, 00002, 00003, to 01000

    With that, I want to get the value of the last number which is 1000. How will I do that?

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: format string to number

    So you have numbers saved as strings but want to return them as numbers?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    Re: format string to number

    yes. I am wondering if the right sql statement is last or max if it will work for varchar type.

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: format string to number

    Quote Originally Posted by codesearcher View Post
    yes. I am wondering if the right sql statement is last or max if it will work for varchar type.
    What is 1000? Is that a field id or a field value?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    Re: format string to number

    Quote Originally Posted by Nightwalker83 View Post
    What is 1000? Is that a field id or a field value?
    that is a value of varchar type

  6. #6
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: format string to number

    Can you please upload the database? I am having a hard time trying to picture what you want.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    Re: format string to number

    Quote Originally Posted by Nightwalker83 View Post
    Can you please upload the database? I am having a hard time trying to picture what you want.
    Nightwalker, can I ask this question anyway.

    1. Can sql MAX query, still get the highest value even if the number is on a varchar field type?
    2. If the record will reach millions, can sql max query handle that record and still have good performance to return the result?

  8. #8
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: format string to number

    Quote Originally Posted by codesearcher View Post
    Nightwalker, can I ask this question anyway.

    1. Can sql MAX query, still get the highest value even if the number is on a varchar field type?
    2. If the record will reach millions, can sql max query handle that record and still have good performance to return the result?
    Yes, SQL shouldn't have any problem with doing that as far as I know.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: format string to number

    Quote Originally Posted by codesearcher View Post
    Nightwalker, can I ask this question anyway.

    1. Can sql MAX query, still get the highest value even if the number is on a varchar field type?
    2. If the record will reach millions, can sql max query handle that record and still have good performance to return the result?
    1: Yes
    2: Yes so long as the field is properly indexed

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    May 2013
    Posts
    1,126

    Re: format string to number

    Thanks guy

  11. #11
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [RESOLVED] format string to number

    Just an observation, wouldn't it have been quicker to actually try it then raise a thread here if you had problems?

Posting Permissions

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



Click Here to Expand Forum to Full Width