?
Solved

SQL Procedures

Posted on 2009-05-09
2
Medium Priority
?
202 Views
Last Modified: 2012-05-06
I have the following problem that I am to answer. Any idea

Write a procedure that takes 5% off of the list price of all of the books that were written by the author who sold the most books in the previous month.  If, for example, the current month is October when the procedure is invoked, it would find the author who sold the most books in September and then discount all of that authors books by 5%



0
Comment
Question by:iolike
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 24346630

create procedure updFivePercentage
as
UPDATE Book
SET SoldPrice = 0.95 * SoldPrice
WHERE AuthorID = (SELECT TOP 1  AuthorID
                  FROM SalesTable
                  WHERE Month (SalesDate) = MONTH(GETDATE() ) -1  
                  GROUP BY AuthorID
                  ORDER BY COUNT(*) DESC
                  )
0
 

Author Closing Comment

by:iolike
ID: 31579849
Thanks
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question