You are here: Re: Calculating Positions Query Required........... « MsSQL Server « IT news, forums, messages
Re: Calculating Positions Query Required...........

Posted by Ed Murphy on 08/31/06 12:47

--[zainy]-- wrote:

> AA Guyz i want to calculate class position of students from a table.
> Sample data is as follows...
>
> Roll # - Name - Marks
> 1 - ABC - 60
> 2 - DEF - 60
> 3 - GHI - 57
> 4 - JKL - 55
> 5 -MNO - 50
> 6 -PQR - 53
>
> The query should return the following result.
>
> Roll # - Name - Marks - POSITION
> 1 - ABC - 60 - 1
> 2 - DEF - 60 - 1
> 3 - GHI - 57 - 3
> 4 - JKL - 55 - 4
> 5 -MNO - 50 - 5
> 6 -PQR - 53 - 6

Try the following:

select a.roll, a.name, a.marks, count(*) + 1 position
from table a
left join table b on b.marks > a.marks
group by a.roll, a.name, a.marks

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация