Hi, I have never written this kind of query, and I don't have any idea where to begin. Some help would be appreciate.

What I have: I have a table with country name, country code, city code, and rate per minute, type (international or local).

I want to make a query which displays the total rate based on where they call and how many minute they used.

1)The problem with this is Some of the country code and city code are anywhere between 1-5 digits. Also, the phone numbers are 7-10 digits.
2) Some country code matches other country code first digit. example. Russia country code = 7, Australia= 715 (these are just examples)
3) Same thing with city codes. example: Russia country code = 7, cities codes in russia = 9, 906, 905, 912.

And I don't want duplicate records.

I did made a query i will post it soon as I find it where I store it and edit this.