Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-09-11 : 14:01:20
|
| Frank Basti writes "I am fairly new to SQL, and this may be something that you have previously come across. Anycase, I have not had any luck finding help on such a subject.Here is my delima.I have a table that consists of the following columns:Cost, Price, Qty_Required.Based on the three columns I have drived a Forumla that will figure out the best Deal for the StooreI also have a ASP Variable with the value of UserRating (this variable holds a determined user value estimate for what a users order is worth to the organization)Profit = ( Price - Cost )/ Qty_Required * UserRatingWhat i want to do is create a simple query but sort it by my dynmaic Profit value.Since not all the numbers that create this value come from values stored in my db, I have no idea how to do a sort.In other words, I want to run a query.Line by line figure out a value, and then sort my record set by the best value.I hope this doesnt sound too confusingThanks in advanceFrank basti" |
|
|
rksingh024
Yak Posting Veteran
56 Posts |
Posted - 2002-09-12 : 03:03:55
|
| You can use the profit in order by clause to get the data sorted by dynamic profit.DECLARE @UserRating intSELECT @UserRating =10SELECT Profit = ( Price - Cost )/ Qty_Required * @UserRatingFROM <tableName>ORDER BY profitRamesh Singh |
 |
|
|
|
|
|