Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an SQL query to get the list of customers' full names with their countries and phone numbers. The customer full name is a space-delimited

Write an SQL query to get the list of customers' full names with their countries and phone numbers.

The customer full name is a space-delimited concatenation of the title (if it exists), first_name, and last_name fields. If the suffix field is present, it should be appended enclosed in parenthesis. In other words, output the full name in the following format:

<first_name> <last_name> (suffix) <p>Output phone numbers in the following format: <phone_country_code>-<phone_area_code>-<phone_number></phone_number></phone_area_code></phone_country_code></p> <p>Be sure to include all customers, even if they are missing some information.</p> <p><img alt="image text in transcribed" src="https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f0cbce4e40b_84666f0cbce23aa9.jpg" style="height:754px; width:1218px"></p> <p><strong><em>Sort the results alphabetically by country and then by phone number in ascending order within each country.</em></strong></p> <p>I currently have this: </p> <p>select CONCAT(c.title,' ' ,c.first_name, ' ',c.last_name,' ',c.suffix) AS "full name", pa.country, concat(p.phone_country_code, '-', p.phone_area_code, '-', p.phone_number) as "phone number"</p> <p>from customer as c -- from customer table with an alias name c left join customer_address AS ca on c.customer_id = ca.customer_id left join physical_address AS pa on ca.physical_address_id = pa.physical_address_id left join phone_number as p on c.customer_id = p.customer_id</p> <p>order by pa.country, p.phone_number asc</p> <p> </p> <p>but I am unsure of how to put the parenthesis arround suffix if exists and the order seems to be off</p> <p> </p> <p> </p></last_name></first_name>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Power Of Numbers In Health Care A Students Journey In Data Analysis

Authors: Kaiden

1st Edition

8119747887, 978-8119747887

More Books

Students also viewed these Databases questions