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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Please help with this query

Author  Topic 

crackalackin
Starting Member

2 Posts

Posted - 2009-11-03 : 05:57:19
Hi!

I have a table with these columns: DatePosted, NumA, NumB. I want to query the db using SELECT so that i have all rows ordered by (NumA+NumB)/Time. Time is the timestamp difference between now and DatePosted. I want to retrieve the data by descending order.

How do I do this? Can you please help me with this query?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-03 : 06:16:28
NumA+NumB devided by Time?

Difference: In Days or Hours or Minutes or ...?

Descending Order: order by what?

Give structure, sample data and example of wanted output please!


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

crackalackin
Starting Member

2 Posts

Posted - 2009-11-03 : 06:32:35
quote:
Originally posted by webfred

NumA+NumB devided by Time?

Difference: In Days or Hours or Minutes or ...?

Descending Order: order by what?

Give structure, sample data and example of wanted output please!


No, you're never too old to Yak'n'Roll if you're too young to die.



I'm sorry, I thought I wrote that. datePosted is in unix_timestamp, and so the denominator Time will be in timestamp.

can I basically do it like this?:
SELECT * FROM table ORDER BY (NumA + NumB) / (NOW() - datePosted) DESC
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-03 : 07:12:59
It looks like you are using MySQL - am I right?
If so: this is an SQL Server forum and it might be that our provided solutions wouldn't work for you.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-03 : 07:37:05
quote:
Originally posted by crackalackin

quote:
Originally posted by webfred

NumA+NumB devided by Time?

Difference: In Days or Hours or Minutes or ...?

Descending Order: order by what?

Give structure, sample data and example of wanted output please!


No, you're never too old to Yak'n'Roll if you're too young to die.



I'm sorry, I thought I wrote that. datePosted is in unix_timestamp, and so the denominator Time will be in timestamp.

can I basically do it like this?:
SELECT * FROM table ORDER BY (NumA + NumB) / (NOW() - datePosted) DESC


What happened when you tried?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -