Solved

SQL Procedures

Posted on 2009-05-09
2
195 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

19 Experts available now in Live!

Get 1:1 Help Now