473,395 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Get possition

hello i have this table

(USERS )
witch have
game_id
user_id
points
---------

in every game user can win points ... what i want is the best way to
Get the position of the user

lets say i want to get the position of the user number 24 ...(up to the
points ) higher points in the Frist and the lowest points in the last

Thanks in advance

Aug 25 '05 #1
3 1194
for this you can fire the following query

select * from USERS where user_id=24 order by points desc

Aug 25 '05 #2
I_love_php wrote:
hello i have this table

(USERS )
witch have
game_id
user_id
points
---------

in every game user can win points ... what i want is the best way to
Get the position of the user

lets say i want to get the position of the user number 24 ...(up to the
points ) higher points in the Frist and the lowest points in the last

Thanks in advance


You didn't say which database or version you're running, but if it supports
subselects something like this might work (warning - not tested):

SELECT count(user_id) FROM table WHERE points > (SELECT points FROM table
WHERE user_id = 24);

Then add 1 to get the user's position. Don't use >= because your user might be
tied with 20 other users - and you'll get an incorrect result.

If your database doesn't support subselects, just do this in two different
SELECT statements (get the points for user_id=24 and use it in the WHERE clause
of the first select).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 25 '05 #3
Thanks alot it is not work but i guess it is a good start let me give u
example of a table
------------------------------------------------------------------------------------
userid points
-----------------------------------------------------------------------------------
3 10
4 5
24 15
4 10
26 11
24 10
3 25
25 1
------------------------------------------------------------------------------------
as you see user number 24 is have 26 points if we sum all the points
user have in this table
what i want to know is the posision of this user
in the example user 24 will be the 2nd here is the order

-------------------------------------------------------------------------------
posistion userid points
------------------------------------------------------------------------------
1 3 35
------------------------------------------------------------------------------
2 24 26
------------------------------------------------------------------------------
3 4 15
------------------------------------------------------------------------------
4 26 11
------------------------------------------------------------------------------
5 25 1
-----------------------------------------------------------------------------

i want this in the Best way becouse i want to add it in all pages so i
dont want my site to be slow

Aug 28 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Zanzibar | last post by:
H In Delphi the Search method has Two return values. 1 Bool to indicate if it is found and 1 integer to return the possition If the bool was false, the index was the possition where the item...
6
by: apm | last post by:
All or rather anyone: I am developing web forms (.aspx pages) that accept inputs from the user at the top of the page. Near the bottom is a submit button. Also near the bottom is a text box...
2
by: | last post by:
Hi, Trying to figure out how i can tell if the scrollbar is in the bottom of my listview, im using the listview to display log files and i track them and add new items to the bottom of the...
5
by: Smoke | last post by:
What i want to do, is, in the Activate Event of my form, determine which is the mouse possition, or, maybe even easy, just determine if the mouse is over my form. I need to do two differents things...
3
by: Lal - Luxor | last post by:
dear all, one of my form have 3 text boxes and 1 button i want to trap my cursor on which text box please help me regards with thanks lal
4
by: nyhetsgrupper | last post by:
I have a C++ application which I am porting to C#. This application is controlling a transport belt. This transport belt is moving bins foreward and backward. I have a state machine controlling...
1
by: johnix | last post by:
i am a bigenner in this field of web programming.. i like to create a dynamic dropdown menu that the data should came from the database but i dont know how to do it. what i did is I use the table and...
7
by: THEAF | last post by:
OK. Im using Access and VB. I have data on two tables in access that I want to show on vb. 1 text box will show 1 data from 1table and same with the other table. i've opened both tables on vb using...
7
by: Johny | last post by:
I have a string of a variable length and I need to split the string in strings of 6 characters . But if the 6th character is not space then I must split the string at possition before the 6th...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.