Oladeji
Oladeji

Reputation: 19

Why Getting duplicate number while using select count(*)?

I'm trying to count/group the number of terminal_id store on my database, but I observed that same number is counted twice. I run the script below

SELECT terminal_id, count(*) AS 'count' from tbl_request_1 GROUP BY terminal_id

and the result is

terminal_id  count
10331317       3
10331349       1
10331368       2
10331377       1
10331901       3
10331901       1
10331902       2
10331904       2
10331905       5
10331905       1

I have 10331905 and 10331901 counted twice however, 10331901 suppose to be 4 and 10331905 suppose to be 6. Note: the data on my db are well formated.

My phpMyAdmin Screenshot Kindly help

Upvotes: 1

Views: 57

Answers (1)

jp_dev
jp_dev

Reputation: 36

Make sure the terminal_id is not an integer. There would be some spaces in it.

Upvotes: 1

Related Questions