|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
creating a SQL Query
Hi friends!
I am facing a difficulty in creating a query in SQL. I have a table name as master which has fields ------------------------------------------------------------------ pid | pretailPrice | pourPrice | cat ------------------------------------------------------------------ 1 10 8 1 2 8 7 1 3 7 5 1 ------------------------------------------------------------------ I am trying to create a query, which calculates discount between pretailprice and pourprice and the output should give the maximum discount from all the records for a particular category i.e 1. Please help Thank you. |
|
#2
|
||||
|
||||
|
SELECT MAX(pourPrice - pretailPrize) as Discount
FROM master GROUP BY cat |
|
#3
|
|||
|
|||
|
Thanx Kris,
The output comes as the max diffrence, but we need to calculate the maximum percentage of discount If we have 3 records for a single category.. --------------------------------------------------------------------------- for eg1 Retail Price is 10, Our Price is 8 equation is 10-8/10 % ---- out put is 20% for eg2 Retail Price is 8, Our Price is 8 equation is 8-7/7 % ---- out put is 12.5% for eg2 Retail Price is 7, Our Price is 5 equation is 7-5/7 % ---- out put is 28.57% --------------------------------------------------------------------------- Now the max is 28.57% correct...I need to prepare a SQL statement which gived the max discounted percentage. I am Sorry for not mentioning percentage before. Thank u. |
|
#4
|
||||
|
||||
|
SELECT MAX((1 - (pourPrice / pretailPrize))*100) as Discount
FROM master GROUP BY cat |
|
#5
|
|||
|
|||
|
Thanx Kris.
Thanks for your help.. I modified your query a bit and got the result.. Thank you. Thanx a lot for your time. Thanx again |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > creating a SQL Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|