Count number of match words

Input:
some random text SELECT TABLE1 some more random text
some random text SELECT TABLE2 some more random text
some random text SELECT TABLE3 some more random text
some random text SELECT TABLE1 some more random text

Output:
'SELECT TABLE1' 2
'SELECT TABLE2' 1
'SELECT TABLE3' 1

I am thinking about using

awk '/SELECT.*/ { [match]++ }'
cat your-file | sort | uniq -c
$ awk '{a[$0]++;next}END{for (i in a){print i,a}}' input.txt
SELECT TABLE1 2
SELECT TABLE2 1
SELECT TABLE3 1

---------- Post updated at 08:40 PM ---------- Previous update was at 08:39 PM ----------

Don't use cat.

you can simply use,

sort filename | uniq -c

Sorry I have miss something in the input file.

I don't think I can use sort and uniq

The new input:
some random text SELECT TABLE1 some more random text
some random text SELECT TABLE2 some more random text
some random text SELECT TABLE3 some more random text
some random text SELECT TABLE1 some more random text

unless, you post the sample file and contents, we cannot give generic code.

$ awk '{for(i=1;i<=NF;i++){if($i~/SELECT/){a[$i" "$(i+1)]++;next}}}END{for (i in a){print i,a}}' a.txt 
SELECT TABLE1 2
SELECT TABLE2 1
SELECT TABLE3 1
perl -lne '(/(SELECT \w+)/)&&$x{$1}++;END{for(sort keys %x){print "$_ $x{$_}"}}' inputfile