2 Replies - 655 Views - Last Post: 25 January 2010 - 09:59 AM Rate Topic: -----

#1 javamad  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 70
  • Joined: 08-June 09

creating a formula from row results and ranking

Post icon  Posted 25 January 2010 - 04:32 AM

Hi
Very new to SQL so apologies.
Say I have a table called results with 3 columns of data (record id, resultA and resultB)

table results
record, A , B
------------------
1 , 5 , 8
2 , 7 , 3
3 , 4 , 4
4 , 5 , 8
:
n , 8 , 1

I would like to create a formula that outputs a result query that ranks the records based on the formula A/B

Could someone give me a hand in figuring this out please
Many thanks

This post has been edited by javamad: 25 January 2010 - 04:33 AM


Is This A Good Question/Topic? 0
  • +

Replies To: creating a formula from row results and ranking

#2 aadam21  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 20
  • Joined: 13-July 09

Re: creating a formula from row results and ranking

Posted 25 January 2010 - 06:01 AM

Hi,

Not sure if this is what you're looking for exactly, but from your question, I took it to mean you want to order the results of your table based on column A and B. If so, use order by A, B in your select statement. This will order the results (ascending by default) by column A, then by column B.
Was This Post Helpful? 0
  • +
  • -

#3 xerxes333  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 504
  • Joined: 05-July 07

Re: creating a formula from row results and ranking

Posted 25 January 2010 - 09:59 AM

@aadam21 I think he(she) wants the results of the calculation A/B sorted ascending. In which case you would want to execute the calculation A/B in the query and sort based on the calculation. A simple example would be
SELECT A/B as calc FROM results ORDER BY calc ASC

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1