Question

In: Computer Science

This requirement can be met by using generic data, the correct mysql coding of script is...

This requirement can be met by using generic data, the correct mysql coding of script is more important than the data.

1. Increase all of the listing prices by 5% for all listings under $500,000 and 10% for all listings $500,000 and higher. Update the listings table with the new prices.

2. Add 30 days to the date expires for all listings. Update the listings table with the new prices.

3. Add "Listing updated on [current date]." to the remarks. Replace [current date] with the current systems date. Do not replace the remarks currently in the table. Add these remarks to the remarks already in the table.

4. Return the following information from the listings table from the stored procedure to display the information in the new real estate app: address, city, state, zip, updated listing price, updated date expires, and updated remarks.

5. Call and run the stored procedure to make the appropriate updates and return the proper results.

Solutions

Expert Solution

Following are the Sql Scripts:

(1) Increase all of the listing prices by 5% for all listings under $500,000 and 10% for all listings $500,000 and higher. Update the listings table with the new prices.

update LISTING
set LISTING_PRICE = LISTING_PRICE +
case
  when LISTING_PRICE < 500000 then (LISTING_PRICE*5)/100
  when LISTING_PRICE >= 500000 then (LISTING_PRICE*10)/100
  else 0
end

(2) Add 30 days to the date expires for all listings.

update LISTING set DATE_EXPIRES = DATEADD(dd, 30, DATE_EXPIRES)

(3) Add "Listing updated on [current date]." to the remarks. Replace [current date] with the current systems date. Do not replace the remarks currently in the table. Add these remarks to the remarks already in the table.

update LISTING set REMARKS=CONCAT(REMARKS ," ","Listing updated on ",GETDATE())

(4) Return the following information from the listings table from the stored procedure to display the information in the new real estate app: address, city, state, zip, updated listing price, updated date expires, and updated remarks.

CREATE PROCEDURE DISPLAYLISTING
AS
BEGIN
select ADDRESS,CITY,STATE,ZIP,LISTING_PRICE,DATE_EXPIRES,REMARKS from LISTING;
END;

(5) Call and run the stored procedure to make the appropriate updates and return the proper results.

In order to execute the stored procedures we use the following SQL script :

EXEC DISPLAYLISTING;

We can update and display the information from the listings table using following stored procedure as :

CREATE PROCEDURE DISPLAYLISTING
AS
BEGIN

update LISTING
set LISTING_PRICE = LISTING_PRICE +
case
  when LISTING_PRICE < 500000 then (LISTING_PRICE*5)/100
  when LISTING_PRICE >= 500000 then (LISTING_PRICE*10)/100
  else 0
end;

update LISTING set DATE_EXPIRES = DATEADD(dd, 30, DATE_EXPIRES);
  
update LISTING set REMARKS=CONCAT(REMARKS ," ","Listing updated on ",GETDATE());

select ADDRESS,CITY,STATE,ZIP,LISTING_PRICE,DATE_EXPIRES,REMARKS from LISTING;

END;


Related Solutions

This requirement can be met by using generic data, the correct mysql coding of script is...
This requirement can be met by using generic data, the correct mysql coding of script is more important than the data. SQL scripts that return data from your database that has already had some processing done to it. Your task is to create these scripts that use built-in SQL functions to return the required data. 1. Create a query for the office table that returns the first 15 characters of the office name, the last two digits of the zip...
Using the sample.sql script, create the sample database in MySQL. Submit the MySQL interactive screen that...
Using the sample.sql script, create the sample database in MySQL. Submit the MySQL interactive screen that results. create database sample; use sample; create table customer (custno int auto_increment primary key, firstname varchar(20), middle varchar(20), lastname varchar(20), address varchar(60), telnum1 varchar(10), telnum2 varchar(10), telnum3 varchar(10), pin varchar(6), email varchar(30)); create table accttype (id int primary key, type varchar(10)); insert into accttype (id, type) values (1,'check'); insert into accttype (id, type) values (2,'save'); insert into accttype (id, type) values (3,'cd'); insert into...
This is in MySQL Part one: Using the MySQL Workbench Data Modeler, construct a diagram that...
This is in MySQL Part one: Using the MySQL Workbench Data Modeler, construct a diagram that shows the table in 3rd Normal Form. Part two: Provide a summary of the steps you took to achieve 3rd Normal form. Include your rationale for new table creation, key selection and grouping of attributes. Table Details: The Anita Wooten Art Gallery wishes to maintain data on their customers, artists and paintings. They may have several paintings by each artist in the gallery at...
coding the following project: Setting up structures to store and retrieve data. A major requirement of...
coding the following project: Setting up structures to store and retrieve data. A major requirement of virtually all projects in the financial world involves the storage and retrieval of data. project must be properly modularized and allow for more than one way to store the data to satisfy the various needs of clients.The first manner is by storing data using hashtables (or hash maps) as the basis of storing and retrieving data.
Solve using coding in R script: 1) Given a standard normal distribution, find the value of...
Solve using coding in R script: 1) Given a standard normal distribution, find the value of k such that P(Z < k) = 0.0197. 2) Given a normal distribution with mu = E(X) = 32 and sigma^2 = V(X) = 30, find the normal curve area to the left of x = 31. Report your code as well as your final answer (4 decimals). 3) A company pays its employees an average wage of $17.90 an hour with a standard...
Using PHP and MYSQL and with a simple customer database, how can I create a simple...
Using PHP and MYSQL and with a simple customer database, how can I create a simple log in and registration system for an ecommerce site
using PDO, MYSQL, and Html, how can i create a simple registration and login form for...
using PDO, MYSQL, and Html, how can i create a simple registration and login form for cPanel?
Data Structures and Algorithms Activity Requirement: Implement a queue using an array as its underline data...
Data Structures and Algorithms Activity Requirement: Implement a queue using an array as its underline data structure. Your queue should fully implemnted the following methods: first, push_back (enqueue), pop_front (dequeue), size, and isEmpty. Make sure to include a driver to test your newly implemented queue
National Correct Coding Initiative (CCI Edits)         INSTRUCTIONS: Review the following code pairs. Determine if you can...
National Correct Coding Initiative (CCI Edits)         INSTRUCTIONS: Review the following code pairs. Determine if you can bill together, assuming documentation supports it. If yes, which code is the second listed code? Make certain you add a modifier -59 to this code. Show exactly how you would bill the code(s). Code Pairs                                          Billable together (Y/N)                      How billed      94010 and 94060 93000 and 92953 30100 and 30200 30801 and 30130 44950 and 50020 50040 and 51702 59400 and 59414 10080 and 10081 12031 and...
Program in Bash: Write a program using bash script that can read a file from the...
Program in Bash: Write a program using bash script that can read a file from the same directory, sort the nonrepeating integers from 0-9 from smallest to largest, and output the results on the same line. Do not use the sort function.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT