php - SELECT DISTINCT + COUNT with some lastIndexOf? -
What I'm trying to do here is to remove the last part of a string. The string always ends in the same way: Abrupt-string, so I search in '-' to remove 'string' (whatever can be done). Meaning: 'Hello-world' to get the 'world'
Works. How can I count the number of times, did SIL found the same 'end-string' while doing its separate tasks? Is it possible to combine in the same question? I am using this question for a PHP project ...
SELECT COUNT (*) SUBSTRING_INDEX ([field or string] from the `last_part` under the table (*) S` `Incidents`, SUBSTRING_INDEX (` field_name`, '-', -1) , [Delimiter], -1) you get the last part (due to -1), and COUNT () related group edit: your title will be "last Index ", by which I think that you can see each group The highest id means that you can do the maximum (`id`) by adding the fields you are selecting SELECT COUNT (*) AS 'occurrences', SUBSTRING_INDEX (`field_name` final_part`
example from table group to` final_per`, maximum `` `_ ``
id | field_name ------------------------ 1 | foo-bar 2 | woo- Bar 3 | woo-foo-buz4 | foo-foo5 | foo-bu 6 | foo-bar 7 | Foo-buzz 8 Kung-Fu 9 Xyz-xyz 10 | 123-xyz Result:
Events | Last_Party | Last_Index_of ---------------------------------------- 3 | Bar 6 2. Falcon | 7 1 Boo 5 2 Fu. 8 Xyz | 10
Comments
Post a Comment