I got the following mysql table
PrefixID + Prefix
001 + 110
005 + 550
005 + 550
005 + 550
005 + 550
and I want to turn it into the following table
PrefixID + Prefix + Count
001 + 110 + 1
005 + 550 + 4
Count is just the frequency of that particular prefix
How can i achieved that?
Use a
GROUP BYclause and aCOUNT()aggregate:From your sample data, it appears that the
PrefixandPrefixIDare dependent (one to one correspondence.) You may need to adjust the query, depending if you want to guarantee that eitherPrefixIDorPrefixis unique in the resultset.