using the code below write a query to display the minimum balance, maximum balance, and average balance for memberships that have a rental CREATE TABLE MEMBERSHIP ( MEM_NUM NUMBER(8,0) PRIMARY KEY, MEM_FNAME VARCHAR2(30) NOT NULL, MEM_LNAME VARCHAR2(30) NOT NULL, MEM_STREET VARCHAR2(120), MEM_CITY VARCHAR2(50), MEM_STATE CHAR(2), MEM_ZIP CHAR(5), MEM_BALANCE NUMBER(10,2) ); CREATE TABLE RENTAL ( RENT_NUM NUMBER(8,0) PRIMARY KEY, RENT_DATE DATE DEFAULT SYSDATE, MEM_NUM NUMBER(8,0) CONSTRAINT RENTAL_MEM_NUM_FK REFERENCES MEMBERSHIP ); INSERT INTO MEMBERSHIP VALUES (102, 'TAMI', 'DAWSON', '2632 TAKLI CIRCLE', 'NORENE', 'TN', '37136', 11); INSERT INTO MEMBERSHIP VALUES (103, 'CURT', 'KNIGHT', '4025 CORNELL COURT', 'FLATGAP', 'KY', '41219', 6); INSERT INTO MEMBERSHIP VALUES (104, 'JAMAL', 'MELENDEZ', '788 EAST 145TH AVENUE', 'QUEBECK', 'TN', '38579', 0); INSERT INTO MEMBERSHIP VALUES (105, 'IVA', 'MCCLAIN', '6045 MUSKET BALL CIRCLE', 'SUMMIT', 'KY', '42783', 15); INSERT INTO MEMBERSHIP VALUES (106, 'MIRANDA', 'PARKS', '4469 MAXWELL PLACE', 'GERMANTOWN', 'TN', '38183', 0); INSERT INTO MEMBERSHIP VALUES (107, 'ROSARIO', 'ELLIOTT', '7578 DANNER AVENUE', 'COLUMBIA', 'TN', '38402', 5); INSERT INTO MEMBERSHIP VALUES (108, 'MATTIE', 'GUY', '4390 EVERGREEN STREET', 'LILY', 'KY', '40740', 0); INSERT INTO MEMBERSHIP VALUES (109, 'CLINT', 'OCHOA', '1711 ELM STREET', 'GREENEVILLE', 'TN', '37745', 10); INSERT INTO MEMBERSHIP VALUES (110, 'LEWIS', 'ROSALES', '4524 SOUTHWIND CIRCLE', 'COUNCE', 'TN', '38326', 0); INSERT INTO MEMBERSHIP VALUES (111, 'STACY', 'MANN', '2789 EAST COOK AVENUE', 'MURFREESBORO', 'TN', '37132', 8); INSERT INTO MEMBERSHIP VALUES (112, 'LUIS', 'TRUJILLO', '7267 MELVIN AVENUE', 'HEISKELL', 'TN', '37754', 3); INSERT INTO MEMBERSHIP VALUES (113, 'MINNIE', 'GONZALES', '6430 VASILI DRIVE', 'WILLISTON', 'TN', '38076', 0); INSERT INTO RENTAL VALUES (1001, '01-MAR-23', 103); INSERT INTO RENTAL VALUES (1002, '01-MAR-23', 105); INSERT INTO RENTAL VALUES (1003, '02-MAR-23', 102); INSERT INTO RENTAL VALUES (1004, '02-MAR-23', 110); INSERT INTO RENTAL VALUES (1006, '02-MAR-23', 107); INSERT INTO RENTAL VALUES (1007, '02-MAR-23', 104); INSERT INTO RENTAL VALUES (1008, '03-MAR-23', 105); INSERT INTO RENTAL VALUES (1009, '03-MAR-23', 111);
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
using the code below write a query to display the minimum balance, maximum balance, and average balance for memberships that have a rental
CREATE TABLE MEMBERSHIP (
MEM_NUM NUMBER(8,0) PRIMARY KEY,
MEM_FNAME VARCHAR2(30) NOT NULL,
MEM_LNAME VARCHAR2(30) NOT NULL,
MEM_STREET VARCHAR2(120),
MEM_CITY VARCHAR2(50),
MEM_STATE CHAR(2),
MEM_ZIP CHAR(5),
MEM_BALANCE NUMBER(10,2)
);
CREATE TABLE RENTAL (
RENT_NUM NUMBER(8,0) PRIMARY KEY,
RENT_DATE DATE DEFAULT SYSDATE,
MEM_NUM NUMBER(8,0) CONSTRAINT RENTAL_MEM_NUM_FK REFERENCES MEMBERSHIP
);
INSERT INTO MEMBERSHIP VALUES (102, 'TAMI', 'DAWSON', '2632 TAKLI CIRCLE', 'NORENE', 'TN', '37136', 11);
INSERT INTO MEMBERSHIP VALUES (103, 'CURT', 'KNIGHT', '4025 CORNELL COURT', 'FLATGAP', 'KY', '41219', 6);
INSERT INTO MEMBERSHIP VALUES (104, 'JAMAL', 'MELENDEZ', '788 EAST 145TH AVENUE', 'QUEBECK', 'TN', '38579', 0);
INSERT INTO MEMBERSHIP VALUES (105, 'IVA', 'MCCLAIN', '6045 MUSKET BALL CIRCLE', 'SUMMIT', 'KY', '42783', 15);
INSERT INTO MEMBERSHIP VALUES (106, 'MIRANDA', 'PARKS', '4469 MAXWELL PLACE', 'GERMANTOWN', 'TN', '38183', 0);
INSERT INTO MEMBERSHIP VALUES (107, 'ROSARIO', 'ELLIOTT', '7578 DANNER AVENUE', 'COLUMBIA', 'TN', '38402', 5);
INSERT INTO MEMBERSHIP VALUES (108, 'MATTIE', 'GUY', '4390 EVERGREEN STREET', 'LILY', 'KY', '40740', 0);
INSERT INTO MEMBERSHIP VALUES (109, 'CLINT', 'OCHOA', '1711 ELM STREET', 'GREENEVILLE', 'TN', '37745', 10);
INSERT INTO MEMBERSHIP VALUES (110, 'LEWIS', 'ROSALES', '4524 SOUTHWIND CIRCLE', 'COUNCE', 'TN', '38326', 0);
INSERT INTO MEMBERSHIP VALUES (111, 'STACY', 'MANN', '2789 EAST COOK AVENUE', 'MURFREESBORO', 'TN', '37132', 8);
INSERT INTO MEMBERSHIP VALUES (112, 'LUIS', 'TRUJILLO', '7267 MELVIN AVENUE', 'HEISKELL', 'TN', '37754', 3);
INSERT INTO MEMBERSHIP VALUES (113, 'MINNIE', 'GONZALES', '6430 VASILI DRIVE', 'WILLISTON', 'TN', '38076', 0);
INSERT INTO RENTAL VALUES (1001, '01-MAR-23', 103);
INSERT INTO RENTAL VALUES (1002, '01-MAR-23', 105);
INSERT INTO RENTAL VALUES (1003, '02-MAR-23', 102);
INSERT INTO RENTAL VALUES (1004, '02-MAR-23', 110);
INSERT INTO RENTAL VALUES (1006, '02-MAR-23', 107);
INSERT INTO RENTAL VALUES (1007, '02-MAR-23', 104);
INSERT INTO RENTAL VALUES (1008, '03-MAR-23', 105);
INSERT INTO RENTAL VALUES (1009, '03-MAR-23', 111);
Step by step
Solved in 4 steps with 2 images