How to answer this hard sql?

The IT Manager of Chinook is interested to find out which email providers their customers are
associated with. Write a single SQL statement to generate a list with 2 columns named Email
Provider and No. of Customers. The email provider should be displayed in all upper cases (e.g.
GMAIL, YAHOO) and such information could be obtained from the email address of the customers.
Email addresses from the same provider with different country codes (e.g.,, should be treated as one email provider. Sort the result of the query first by No. of
Customers in decending order, and then by Email Provider in assending order.

What I have tried:

        Substr(email, Instr(Email), "@")+1,
        25-Instra(Substr(Substr(Email, "@")," "),".") AS "Email Provider", 
        COUNT(*) AS "No of Customers" 
        UPPER(substr(Email,Instr(Email, "@")+2,Length(Substr(Substr(Email, "@"),".")"."));

Source: sql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.