Explore BrainMass
Share

Write a SQL query that returns the names of the students

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Write a SQL query that returns the names of the students (lname, fname), and the major of the major with most students. If more than one major is tied for most students, then list all the names of the students from both majors (as well as the majors). Order the results by major (in the case of a tie) and then alphabetically by last name and first name.

Table Data:
id, fname, lname, major

1;"Jeff";"Salvage";"Computer Science"
2;"Thurman";"Munson";"Computer Science"
3;"Chase";"Utley";"Physical Fitness"
4;"Jimmy";"Rollins";"Computer Science"
5;"Derek";"Jeter";"World Series Championships"
6;"Jeff";"Popyack";"Mathematics"
7;"Kurt";"Schmidt";"Mathematics"
8;"Jason";"Lenhart";"Mathematics"
;"";"";""

Table SQL:

-- student information
CREATE TABLE Student (
id SERIAL PRIMARY KEY, -- student id number
fname VARCHAR(20) NOT NULL, -- first name
lname VARCHAR(20) NOT NULL, -- last name
major VARCHAR(60) NOT NULL -- major
);

INSERT INTO Student (fname, lname, major) VALUES ('Jeff', 'Salvage', 'Computer Science');
INSERT INTO Student (fname, lname, major) VALUES ('Thurman', 'Munson', 'Computer Science');
INSERT INTO Student (fname, lname, major) VALUES ('Chase', 'Utley', 'Physical Fitness');
INSERT INTO Student (fname, lname, major) VALUES ('Jimmy', 'Rollins', 'Computer Science');
INSERT INTO Student (fname, lname, major) VALUES ('Derek', 'Jeter', 'World Series Championships');
INSERT INTO Student (fname, lname, major) VALUES ('Jeff', 'Popyack', 'Mathematics');
INSERT INTO Student (fname, lname, major) VALUES ('Kurt', 'Schmidt', 'Mathematics');

© BrainMass Inc. brainmass.com October 25, 2018, 3:08 am ad1c9bdddf
https://brainmass.com/computer-science/sql/write-sql-query-returns-names-students-328197

Solution Preview

Please check attachment.

Here is simple SQL query:

SELECT lname,fname,major
FROM ...

Solution Summary

The expert writes a SQL query that returns that names of the students.

$2.19
See Also This Related BrainMass Solution

E-Business Project Plan

You have decided develop an eCommerce site while still working your 'day job' in the hopes that you will one day be able to derive all of your income from your eCommerce site.
In 500 - 600 words how you would you go about doing this; what factors would you have to take into consideration, what kind of product or service would you market, how would you find customers, what would some of the obstacles be, etc.

Why is it important to create an e-business project plan?

Why is it that the managers ignore planning?

What are the most important elements in conducting a technology alternatives cost analysis?

Describe your experiences with cost estimation and scheduling.

View Full Posting Details