私はアプリケーションテーブルを格納するSQLテーブルを持っています。私はこの例のように値を格納する列の誤り、どのように値が変数のようなSQLで最も頻繁な値を取得するのですか?
+------+--------+----------------------------------------------+
| id | name | error |
+------+--------+----------------------------------------------+
| 1 | john | Flushing folder error on folderid 456 |
| 2 | paul | Flushing folder error on folderid 440 |
| 3 | gary | Error connection has timed out on source 320|
| 4 | ade | Error connection has timed out on source 220|
| 5 | fred | Error connection has timed out on source 821|
| 6 | bob | Reading errors occured on folder 400 |
| 7 | ade | Error connection has timed out on source 320|
| 8 | fred | Error connection has timed out on source 320|
| 9 | bob | Reading errors occured on folder 402 |
| 10 | ade | Error connection has timed out on source 320|
| 11 | fred | Error connection has timed out on source 320|
| 12 | bob | Reading errors occured on folder 400 |
| 13 | paul | Flushing folder error on folderid 100 |
+------+--------+----------------------------------------------+
を持っている私が取得したいと思い、結果は次のようなものです:
+-------------------------------------------+------------+
| Error Like | Occurence |
+-------------------------------------------+------------+
| Error connection has timed out on source | 7 |
| Flushing folder error on folderid | 3 |
|Reading errors occured on folder | 3 |
+-------------------------------------------+------------+
は、私はSQLであることを行うことがとにかくありますか?エラーは変数であり、考えられるすべてのエラーの網羅的なリストはありません。
ありがとうございます!
これにより、問題が部分的に解決されます。 "xxxxフォルダのエラー"のようなエラーが発生することがあります。ここの数字部分は、エラーメッセージの最後の4文字ではありません。 –
@RafaAyadi:問題の正確な説明を入力しないと、適切な答えを得ることは困難です。 –
次に、 'REARSE'で' CHARINDEX'を使用するかもしれません。 – Wanderer