1- Write a query to select each person’s name and their phone number for everyon
ID: 3698056 • Letter: 1
Question
1- Write a query to select each person’s name and their phone number for everyone whose names starts with “ag”. Pay attention to the formatting and column heading of the phone number. (The output should be like as shown in the image)
2- Write a query to show the 5 digit zipcodes that are in the database. There should be no repeats and only the first 5 digits should be shown. Sort your results in ascending order. The column should have the heading ‘Zip’.(The output should be like as shown in the image)
3- Write a query to determine how many people have an 800 number. (The output should be like as shown in the image)
4- Alphabetically, who are the first and last people in the table? (The output should be like as shown in the image)
5- Write a query to determine how many people have an 800 number in each of the New England states. (ME, NH, VT, MA, RI, CT) (The output should be like as shown in the image)
6- Write a query to determine which states have more than 1000 contacts; (The output should be like as shown in the image)
7- Write a query to determine which states have more than 50 contacts whose name starts with ‘p’; (The output should be like as shown in the image)
Explanation / Answer
1. Select name,Number as PhoneNumber from table where name like 'Ag%';
2.Select unique zip as Zip from table where LEN(zip)=5 LIMIT 5 order by zip asc;
3.select toll-freecontact,count(*) from table where number='800';
4.Select first as First,last as Last from table order by first asc,last desc LIMIT 1;
6 Select state as State,count(*) as ContactCount from table where count(contacts)>1000 group by state;
7 Select state as State,count(*) as ContactCount from table where count(contacts)>50 and state like 'p%' group by state;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.