1) Ensure that the FINANCING_PLANS, DEALERSHIPS, VEHICLES, and TIME (or TIMES if you desire) dimension tables and the SALES_FACTS fact table are created and populated.
2) Create a user-defined function called VEHICLES_BY_VEHICLE_TYPE that receives an input parameter of a concatenated make and model and then queries the VEHICLES and SALES_FACTS tables to return the total vehicles sold by that combination. Execute your function for a sample input value of your choosing to demonstrate that it works correctly.
3) Create a user-defined function called DOLLARS_BY_VEHICLE_TYPE that receives an input parameter of a concatenated make and model and then queries the VEHICLES and SALES_FACTS tables to return the total gross sales amount of the sales by that combination. Execute your function for a sample input value of your choosing to demonstrate that it works correctly.
4) Create a stored procedure called STATS_BY_VEHICLE_TYPE that receives an input parameter of the concatenated make and model and then calls your two user-defined functions VEHICLES_BY_VEHICLE_TYPE and DOLLARS_BY_VEHICLE_TYPE. Execute your stored procedure for the same sample input values used earlier to demonstrate that it works correctly.
5) Develop an SQL query to determine which holiday had the most sales and then drill down via another query to determine for that holiday which dealership, by zip code, had the most sales. Then drill down by another query to determine for that holiday which dealership, by zip code, and make had the most sales.
6) Develop an SQL query to determine how many days, by day type, didn’t have more than 5 vehicles and $100,000 total sales. In order to achieve a fair comparison, analyze your results by the total number of weekdays, weekend days, and holidays in your TIMES table.
All SQL and PL/SQL should be executed via one or more SQL script files. The best approach is to have separate SQL script files for each step and then an SQL script file that calls all of them in sequence. Submit SQL*Plus SPOOL files produced by your SQL and PL/SQL showing all your SQL and PL/SQL code and the results, or if using iSQL*Plus or other GUI (e.g. SQL Developer), a single Word or PDF file of screen snapshots showing both your SQL and PL/SQL and the results. Do NOT submit your SQL script file.
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.create or replace function VEHICLES_BY_VEHICLE_TYPE (make_model in varchar2) return number is
make_ varchar2 (100);
sold := 0 ;
spaces := 0;
select (length(make_model) - length(replace(make_model,' '))) into spaces from dual;
if spaces < 1 then
end if ;
select REGEXP_SUBSTR(make_model, '[^ ]+', 1, 1) into make_ from dual;
spaces := spaces + 1;
select REGEXP_SUBSTR( make_model, '[^ ]+', 1, spaces) into model_ from dual ;...