How can i count each digit occurence in a given filed and insert in a seperate column sql or vertica SQL.
below is the example. Tab1 table is having ac_number column.
Tab1
ac_number
12344665533334
12304885577339
Tab2
c0 c1 c2 c3 c4 c5 c6 c7 c8 c9
0 1 1 5 3 2 2 0 0 0
1 1 1 3 1 2 0 2 2 1
You can use regexp_count()
function:
SELECT regexp_count(ac_number, '0') as c0,
regexp_count(ac_number, '1') as c1,
etc...
From yourtable;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.