YSQL [jsohn6]> SELECT * FROM SCHOOL;lySQL [jsohn6]> SELECT * FROM DEPARTMENT;SCHOOL_CODEDEPARTMENT_ID| DEPARTMENT_ID |DEPARTMENT_NAME101SCHOOL OF MERCHANDISINGFASHION DESIGN101SCHOOL OF FASHION DESIGN102ADVERTISING102103|201||202 |SCHOOL OF GRAPHIC DESIGNGRAPHIC DESIGN103SCHOOL OF FINE ARTS201FINE ARTSSCHOOL OF DESIGN AND TECHNOLOGDESIGN AND TECHNOLOGY202rows in set (0.00 sec)MYSQL [jsohn6]> SELECTFROM PROFESSOR;MYSQL [jsohn6]> SELECT * FROM TECHNOLOGY;| PROF_NUM | PROF_LASTNAMEPROF_FIRSTNAMECOURSE_TYPE | LABTOP_NUMBER1 | Smith2 | Banks3 | Taylor4 | Smith6 | Smith7 | BanksMary| JaneTECH-10012345HazelTECH-11067890TerryTECH-12013579| Jenny| Tim24680TECH-2004 rows in set (0.00 sec)6 rows in set (0.00 sec) VSQL [jsohn6]> SELECTFROM COURSE;COURSE_TYPE | PROF_NUM | DEPARTMENT_ID | COURSE_TITLE| COURSE_DESCRIPTION| COURSE_TYPE_CODE |101 | Costume Designs101 | Couture Fashion101 | Costume Designs101 | Textile Designs201 | Fine Arts103 | Computer Patterns103 | Web Retail103 | Web Design202 | Design with Technolo | Intro to Computer Design| Fundamentals of Costume Design | F| Fundamentals of Luxury Design | F| Fundamentals of Costume Design | F| Fundamentals of Textile Design | FAdvanced Printmaking| Intro to Computer PatternsFASH-100FASH-110FASH-120FASH-150FASH-2104 |2 |4 |2 |TECH-100Intro to Retail EcommerceTECH-110| Fundamentals of Graphic Design | TTECH-120TECH-200rows in set (e.01 sec)MYSQL [jsohn6]> SELECT * FROM FASHION;COURSE_TYPE | RUNWAY_DATE| 2020-05-27| 2020-05-27| 2020-05-27| 2020-05-28| 2020-05-28FASH-100FASH-110FASH-120FASH-150FASH-210rows in set (0.00 sec)

Question
Asked Dec 13, 2019
2 views

Create a complex query based on two or more tables (SCHOOL, DEPARTMENT, PROFESSOR, TECHNOLOGY, COURSE, & FASHION tables attached) which includes either several conditions or a subquery (or both).

YSQL [jsohn6]> SELECT * FROM SCHOOL;
lySQL [jsohn6]> SELECT * FROM DEPARTMENT;
SCHOOL_CODE
DEPARTMENT_ID
| DEPARTMENT_ID |
DEPARTMENT_NAME
101
SCHOOL OF MERCHANDISING
FASHION DESIGN
101
SCHOOL OF FASHION DESIGN
102
ADVERTISING
102
103|
201||
202 |
SCHOOL OF GRAPHIC DESIGN
GRAPHIC DESIGN
103
SCHOOL OF FINE ARTS
201
FINE ARTS
SCHOOL OF DESIGN AND TECHNOLOG
DESIGN AND TECHNOLOGY
202
rows in set (0.00 sec)
MYSQL [jsohn6]> SELECT
FROM PROFESSOR;
MYSQL [jsohn6]> SELECT * FROM TECHNOLOGY;
| PROF_NUM | PROF_LASTNAME
PROF_FIRSTNAME
COURSE_TYPE | LABTOP_NUMBER
1 | Smith
2 | Banks
3 | Taylor
4 | Smith
6 | Smith
7 | Banks
Mary
| Jane
TECH-100
12345
Hazel
TECH-110
67890
Terry
TECH-120
13579
| Jenny
| Tim
24680
TECH-200
4 rows in set (0.00 sec)
6 rows in set (0.00 sec)
help_outline

Image Transcriptionclose

YSQL [jsohn6]> SELECT * FROM SCHOOL; lySQL [jsohn6]> SELECT * FROM DEPARTMENT; SCHOOL_CODE DEPARTMENT_ID | DEPARTMENT_ID | DEPARTMENT_NAME 101 SCHOOL OF MERCHANDISING FASHION DESIGN 101 SCHOOL OF FASHION DESIGN 102 ADVERTISING 102 103| 201|| 202 | SCHOOL OF GRAPHIC DESIGN GRAPHIC DESIGN 103 SCHOOL OF FINE ARTS 201 FINE ARTS SCHOOL OF DESIGN AND TECHNOLOG DESIGN AND TECHNOLOGY 202 rows in set (0.00 sec) MYSQL [jsohn6]> SELECT FROM PROFESSOR; MYSQL [jsohn6]> SELECT * FROM TECHNOLOGY; | PROF_NUM | PROF_LASTNAME PROF_FIRSTNAME COURSE_TYPE | LABTOP_NUMBER 1 | Smith 2 | Banks 3 | Taylor 4 | Smith 6 | Smith 7 | Banks Mary | Jane TECH-100 12345 Hazel TECH-110 67890 Terry TECH-120 13579 | Jenny | Tim 24680 TECH-200 4 rows in set (0.00 sec) 6 rows in set (0.00 sec)

fullscreen
VSQL [jsohn6]> SELECT
FROM COURSE;
COURSE_TYPE | PROF_NUM | DEPARTMENT_ID | COURSE_TITLE
| COURSE_DESCRIPTION
| COURSE_TYPE_CODE |
101 | Costume Designs
101 | Couture Fashion
101 | Costume Designs
101 | Textile Designs
201 | Fine Arts
103 | Computer Patterns
103 | Web Retail
103 | Web Design
202 | Design with Technolo | Intro to Computer Design
| Fundamentals of Costume Design | F
| Fundamentals of Luxury Design | F
| Fundamentals of Costume Design | F
| Fundamentals of Textile Design | F
Advanced Printmaking
| Intro to Computer Patterns
FASH-100
FASH-110
FASH-120
FASH-150
FASH-210
4 |
2 |
4 |
2 |
TECH-100
Intro to Retail Ecommerce
TECH-110
| Fundamentals of Graphic Design | T
TECH-120
TECH-200
rows in set (e.01 sec)
MYSQL [jsohn6]> SELECT * FROM FASHION;
COURSE_TYPE | RUNWAY_DATE
| 2020-05-27
| 2020-05-27
| 2020-05-27
| 2020-05-28
| 2020-05-28
FASH-100
FASH-110
FASH-120
FASH-150
FASH-210
rows in set (0.00 sec)
help_outline

Image Transcriptionclose

VSQL [jsohn6]> SELECT FROM COURSE; COURSE_TYPE | PROF_NUM | DEPARTMENT_ID | COURSE_TITLE | COURSE_DESCRIPTION | COURSE_TYPE_CODE | 101 | Costume Designs 101 | Couture Fashion 101 | Costume Designs 101 | Textile Designs 201 | Fine Arts 103 | Computer Patterns 103 | Web Retail 103 | Web Design 202 | Design with Technolo | Intro to Computer Design | Fundamentals of Costume Design | F | Fundamentals of Luxury Design | F | Fundamentals of Costume Design | F | Fundamentals of Textile Design | F Advanced Printmaking | Intro to Computer Patterns FASH-100 FASH-110 FASH-120 FASH-150 FASH-210 4 | 2 | 4 | 2 | TECH-100 Intro to Retail Ecommerce TECH-110 | Fundamentals of Graphic Design | T TECH-120 TECH-200 rows in set (e.01 sec) MYSQL [jsohn6]> SELECT * FROM FASHION; COURSE_TYPE | RUNWAY_DATE | 2020-05-27 | 2020-05-27 | 2020-05-27 | 2020-05-28 | 2020-05-28 FASH-100 FASH-110 FASH-120 FASH-150 FASH-210 rows in set (0.00 sec)

fullscreen
check_circle

Expert Answer

Step 1

Query:

SELECT A.SCHOOL_CODE, a.DEPARTMENT_ID
FROM SCHOOL A
WHERE A.DEPARTMENT_ID =
(SELECT DEPARTMENT_ID
FROM DEPARTMENT
WHERE DEPARTMENT_ID = 202);

Step 2

Explanation:

The above query is an example of subquery. Here, select a “SCHOOL_CODE”  and "DEPARTMENT_ID"from the “SCHOOL” t...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: A class Climber has been defined, and the variable cat refers to an instance of Climber. Call the me...

A: Method calling in pythonIn python, a class climber has been defined. Variable cat refers to an insta...

question_answer

Q: Output the information as a formatted histogram. Each name is right justified with a setw() value of...

A: Program:#include <iostream>#include <string>#include <iomanip> using namespace std...

question_answer

Q: Users can request certificates that aren't configured for autoenrollment by using the Certificates s...

A: The given statement is true i.e. By using the snap-in Certificates, users can request certificates t...

question_answer

Q: Hi, I am programming in java. The instructions require: Create a new project and call it Project8. C...

A: All the changes are commented above the modified or added line.In main() method Mymethod() called an...

question_answer

Q: Given the Boolean function F = xy + x’y’ + y’z 1. Implement it with AND, OR, and inverter 2. Impleme...

A: a) Implementing the given Boolean function by using AND, OR and NOT gate:F = xy + x'y' + y'z Logic c...

question_answer

Q: What are the SQL query commands to create the tables (attached) with appropriate attributes and data...

A: Primary key:A primary key is a minimum set of attributes (columns) in a table with uniquely defined ...

question_answer

Q: - Give everybody 10% salary increase in the departments whose maximum salaries are less than 2000

A: Create a table and name it as EMP.Syntax to create a table –CREATE TABLE table_name (    column1 dat...

question_answer

Q: Write one Python statement to print variable price in currency format (with commas for thousands).

A: Program:price = 78200000print("\nOriginal Number: ", price)print("Printing in currency format: "+"{:...

question_answer

Q: Write one Python statement to start and continue a while loop while variable name is not an empty st...

A: While loop:With the while loop, if a condition is valid, we may execute a series of statements.Synta...