Skip to content
Advertisement

Tag: string

Getting NULL after combining strings between date functions

Given a date column with a value 2020-05-01, I want to return 2020-Q2. The QUARTER() function is not available due to the Hive version we are using. I can get the quarter number with: (INT((MONTH(yyyy_mm_dd)-1)/3)+1). When I try to combine this with the YEAR() function and strings, I get null: How can I properly concatenate this to get the desired

How to count non-zero numbers in a comma separated string in oracle sql

Want to count non-zero numbers from a comma separated string in oracle 12.10. If my column has data as 2000,300,0,0 then count it as 2. This gives me 2000 and 300 as result but what’s next to count it. select regexp_substr(‘2000,300,0,0′,'[^,]+’,1,level) from dual connect BY to_number(regexp_substr(‘2000,300,0,0’, ‘[^,]+’,1,level)) > 0 Thanks for helping me. I know I am missing a basic

How to sort numbers last in PostgreSQL?

Found many related answers, but nothing that did this. How to sort by numbers last: And, preferably (but not necessary) PostgreSQL 11.9 Also, probably don’t want to use a regex for performance reasons. Don’t want to create an index either… Answer I think a regex is the right way to do this: This puts first rows that contain no digit

Advertisement