SQL Query | How to trim leading zeroes | PATINDEX

แชร์
ฝัง
  • เผยแพร่เมื่อ 19 ม.ค. 2025

ความคิดเห็น • 9

  • @Robert8455
    @Robert8455 2 ปีที่แล้ว

    Thanks! Very well explained, you have a new subscriber.

  • @adilumr6359
    @adilumr6359 8 หลายเดือนก่อน

    How to replace leading zeroes with another character

  • @Gaurav-vf2tr
    @Gaurav-vf2tr 2 ปีที่แล้ว

    Hi firstly I want to appreciate your teaching method is to much good.. ..
    Also if there any upcoming course for SQL- power bi. Then. Plz inform us ... Waiting for your positive response..😇

    • @LearnatKnowstar
      @LearnatKnowstar  2 ปีที่แล้ว

      Thank you for your support. We will be planning the courses soon 🙏

  • @erikaruv22
    @erikaruv22 2 ปีที่แล้ว

    How would you remove zeros after a decimal for an entire column? Example 62.000000000. Remove the decimal and all zeros after for the whole column.
    I'm new to SQL and cant seem to fins the right query. Thanks

    • @MK-lh3xd
      @MK-lh3xd 2 ปีที่แล้ว

      In MySQL, you can do select cast(62.000000 as float); It will output 62. If you have 62.0000100, then the output will be 62.00001

  • @nikolaybaranov2213
    @nikolaybaranov2213 2 ปีที่แล้ว

    Thank you! This is interesting, but such code is poorly understood and not portable. IMHO it's better to use the classic CASE.
    SELECT
    CASE WHEN PATINDEX('%[^0]%', @col)>0 THEN SUBSTRING(@col, PATINDEX('%[^0]%', @col) , len(@col))
    ELSE ''
    END

    • @LearnatKnowstar
      @LearnatKnowstar  2 ปีที่แล้ว

      Thank you for sharing your thoughts. It really helps us all learn and grow 🙏