Solved

SQL Procedures

Posted on 2009-05-09
2
197 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
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
passing parameter in sql procedure 9 61
Need help debbuging stored procedure 21 41
Sql Server group by 10 24
Find results from sql within a time span 11 29
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now