Q1:
A: There are two tables in a telecom SQL Server database – Customers and Rates as shown below:
Customers
PK CustomerPhoneNumber varchar(15) CustomerType int -the type of customer
Rates
FK CustomerType int - the type of customer CountryCode varchar(4) – the country calling code Rate float - the rate per minute of phone call
Example country codes:
1 – USA 1809 – Dominican Republic 44 – Great Britain 359 – Bulgaria
So a phone number in USA would be 13104405609.
As shown in the table the rates depend on the customer type and the country called.
Given the full originating and destination phone numbers (including country codes) of a call and its duration in minutes, write a single SQL statement to calculate the cost of the call.
For convenience, let the parameters for the SQL statement be called @FromPhoneNumber, @ToPhoneNumber, @Duration.