Question

In: Computer Science

The purpose of this exercise is to provide the Marketing department with a method to sort...

The purpose of this exercise is to provide the Marketing department with a method to sort a predefined data list by zip code, last name, first name so they can take advantage of bulk mailing rates.   
Assignment: 1. Create a table with the following fields called "Homework1Data" with (4 fields), then run the inserts below into the table (Figure 1-1). 2. Write a single SQL Query that has the following fields (6 fields so they can easily be moved around using a Mail Merge) using these names (alias); Firstname, Lastname, Address, City, State, Zip be sure to sort by zip code, last name, first name 3. Turn in a copy of your SQL Query (single statement - not a procedure)
Hint: The magic exist in the string manipulation functions (LENGTH, INSTR, SUBSTR, etc.)
Figure 1-1:

CREATE TABLE homework1data ( name VARCHAR2(30), address VARCHAR2(30), location VARCHAR2(30), zip VARCHAR2(10)); ----------------------------------------- INSERT INTO Homework1Data (Name, Address, Location, Zip) VALUES ('Ferguson, Shawn M.', '1940 Fountainview Court', 'Reynoldsburg, Ohio', '43068'); INSERT INTO Homework1Data (Name, Address, Location, Zip) VALUES ('Phillips, George', '19 Pleasant St.', 'Columbus, OH', '43231'); INSERT INTO Homework1Data (Name, Address, Location, Zip) VALUES ('Thompson, Mary', '200 E. Main St.', 'Columbus, Oh', '43215'); INSERT INTO Homework1Data (Name, Address, Location, Zip) VALUES ('Swatson, Robert', '584 Yellowstone Dr.', 'Westerville, OH', '43081'); INSERT INTO Homework1Data (Name, Address, Location, Zip) VALUES ('Banks, Heather T.', '19 Pleasant St.', 'Columbus, Ohio', '43231');

Solutions

Expert Solution

Query

SELECT
SUBSTR(name, 1, INSTR(name,',')-1) AS FirstName,
SUBSTR(name, INSTR(name,',') + 1, LENGTH(name)) AS LastName,
address,
SUBSTR(location, 1, INSTR(location,',')-1) AS City,
SUBSTR(location, INSTR(location,',') + 1, LENGTH(location)) AS State,
zip
FROM homework1data
order by Zip,LastName,FirstName;

SUBSTR(name, 1, INSTR(name,',')-1) AS FirstName --- selects name from 1st index till the index which has comma(,)

SUBSTR(name, INSTR(name,',') + 1, LENGTH(name)) AS LastName --- selects all characters after comma(,) till the end

Output


Related Solutions

Please check my work. The purpose of this exercise is to provide students with the opportunity...
Please check my work. The purpose of this exercise is to provide students with the opportunity to normalize data. Assignment: Identify what fields from the list below belong to which table. If you are uncertain, place the field under the column with your argument on why it should belong. Write your answers in the columns below the table names. COURSE FACULTY LOCATION SECTION STUDENT CourseID CourseNumber CourseName CreditHours Status Description Days StartTime EndTime FacultyID Status FirstName LastName WorkPhone HomePhone CellPhone...
What sort of marketing services does it provide through its Amazon Business Seller program?
Amazon Business is a B2B e-marketplace .What sort of marketing services does it provide through its Amazon Business Seller program?
This is an exercise in correctly implementing insertion sort and selection sort. This assignment includes a...
This is an exercise in correctly implementing insertion sort and selection sort. This assignment includes a text data file containing information on tutorial websites for a variety of programming languages. The data file is named Tutorials. It contains records of programming tutorial websites. The record structure for this text file is: FIELD 1 = Programming Language FIELD 2 = Name and Description of Website FIELD 3 = URL Web Address of Language Tutorial The structure of the file is that...
- The purpose of a marketing plan, - The importance of developing marketing goals, - An...
- The purpose of a marketing plan, - The importance of developing marketing goals, - An example of a quantitative marketing goal and a qualitative marketing goal, - Ways to determine if you are achieving your marketing goals outlined in your marketing plan.
Team/Deparment Coaching Analyse the starting situation of the Online Marketing Department: To provide context, explain what...
Team/Deparment Coaching Analyse the starting situation of the Online Marketing Department: To provide context, explain what the starting situation is, from an analytical perspective. Explain the importance of carrying out a coaching process; what could happen if you do not act quickly, and what benefits would be obtained after the intervention.
PROVIDE CODE ONLY IN C++ / NO OTHER LANGUAGES PLEASE ADD SELECTION SORT/ INSERTION SORT/ AND...
PROVIDE CODE ONLY IN C++ / NO OTHER LANGUAGES PLEASE ADD SELECTION SORT/ INSERTION SORT/ AND BUBBLE SORT FUNCTION TO THIS PROGRAM #include <iostream> #include<vector> #include <algorithm >   #include <chrono>    #include <ctime> using namespace std; void bubblesSort() { // Please create Bubble Sort function// Make another for Selection Sort and  Insertion Sort } int main() { // empty vector vector<int> data; // data [0], data [1]... data[N-1] <-- end(data) // set of values to test N for (auto N :...
Exercise 4–Timing Sorting AlgorithmCollect the run times for either selection sort or insertion sort (use random...
Exercise 4–Timing Sorting AlgorithmCollect the run times for either selection sort or insertion sort (use random values for an array and sorted values; sorted the same list twice and collect time each time) for the following array sizes: 1000, 2000, and 10000. You should be able to confirm that the runtime is n^2 for unsorted list (i.e., going from 1000 to 2000 should be about 4 times slower and going from 1000 to 10000 should be about 100times slower). Question...
Write a very general sort method that can sort any type of data arrays/lists. For example,...
Write a very general sort method that can sort any type of data arrays/lists. For example, can sort a list of integers in ascending order, a list of integers in descending order, a list of doubles, a list of student objects (with names and scores) in ascending order of names, or in descending order of scores, … You can use any pre-defined sort function or can code your own. Use your favorite language for implementation. If your language doesn’t support...
Implement heap sort by using the bottom-up insertion method. Add this sort to your sorting framework....
Implement heap sort by using the bottom-up insertion method. Add this sort to your sorting framework. Evaluate its performance in terms of the numbers of comparisons and exchanges, and compare it to the performance of the two advanced sorting methods that you have previously implemented. Submit your report with detailed empirical results and a thorough explanation of these results. Which of the three advanced sorting method is the best choice for a) ordered data, b) data in reverse order, and...
Is marketing control really necessary in a marketing plan or is it an optional managerial exercise?
Is marketing control really necessary in a marketing plan or is it an optional managerial exercise?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT