Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
% Calculations in SQL
Old 10-04-2006, 08:34 AM % Calculations in SQL
tomcat_fo's Avatar
Ultra Talker

Posts: 275
Trades: 0
I want do calculate the downcout in % in price between two prices ("fyrrpris" and "nupris") - then i want it do be sorted so that the largest downcut in % is first on the list.

Have made the calculation in the querry, but it will not work.... probably the syntax....

$weather2 = mysql_db_query("$datab", "select id, lutnavn, lysing, fyrrpris, nupris, mynd, firmaid, bolkid, timestamp, ip, active from tilbud where active=1 and bolkid=$bolkur order by ((fyrrpris-nupris)/fyrrpris)*100 DESC");;
while ($row = mysql_fetch_array ($weather2))
{
$id = "".$row["id"];
$lutnavn = "".$row["lutnavn"];
$lysing = "".$row["lysing"];
$fyrrpris = "".$row["fyrrpris"];
$nupris = "".$row["nupris"];
$mynd = "".$row["mynd"];
$firmaid = "".$row["firmaid"];
$bolkid = "".$row["bolkid"];
$timestamp = "".$row["timestamp"];
$ip = "".$row["ip"];
$active = "".$row["active"];
$sparing = (($fyrrpris-$nupris)/$fyrrpris)*100;
}
}

I get this message when that runs:


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/home/web/xxxxxxxx/xxxxxxx/tilbudviewlist.php on line 10

Last edited by tomcat_fo; 10-04-2006 at 11:28 AM..
tomcat_fo is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-06-2006, 08:20 AM Re: % Calculations in SQL
jito's Avatar
MY LIFE IS 'i' LIFE

Posts: 565
Name: surajit ray
Location: inside the heart of my friends
Trades: 0
you have error in ur query.
select (fyrrpris-nupris)/fyrrpris)*100....
__________________
I am not smart, that's why i don't act smart


Please login or register to view this content. Registration is FREE

Last edited by jito; 10-06-2006 at 08:26 AM..
jito is offline
Reply With Quote
View Public Profile
 
Old 10-07-2006, 11:49 AM Re: % Calculations in SQL
tomcat_fo's Avatar
Ultra Talker

Posts: 275
Trades: 0
Quote:
Originally Posted by jito View Post
you have error in ur query.
select (fyrrpris-nupris)/fyrrpris)*100....

Have tryed that... it does not work.
tomcat_fo is offline
Reply With Quote
View Public Profile
 
Old 10-07-2006, 07:14 PM Re: % Calculations in SQL
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
not tested this but

SELECT ((fyrrpris-nupris)/fyrrpris)*100 as calc, rest_of_fieldlist FROM .... ORDER BY calc DESC

should work
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to % Calculations in SQL
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16058 seconds with 12 queries