473,396 Members | 1,996 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,396 software developers and data experts.

Distinct Top Records From Table

Hi


Please help me on this its URGENT.....


I have one Table from which I want Distinct Top Records. Means I need the such records in which there should be only one user with highest no of votes of particular round

ROUND 1
User | Votes | ENTRY(PK)
1 20 1
2 25 2
1 35 3
2 45 4
3 55 5
1 75 6

The Output should be something like this.

User | Votes | Entry
1 75 6
3 55 5
2 45 4


Please can any one help me on this I had tried a lot but I didn't get the result
Oct 30 '07 #1
3 1228
amitpatel66
2,367 Expert 2GB
Hi


Please help me on this its URGENT.....


I have one Table from which I want Distinct Top Records. Means I need the such records in which there should be only one user with highest no of votes of particular round

ROUND 1
User | Votes | ENTRY(PK)
1 20 1
2 25 2
1 35 3
2 45 4
3 55 5
1 75 6

The Output should be something like this.

User | Votes | Entry
1 75 6
3 55 5
2 45 4


Please can any one help me on this I had tried a lot but I didn't get the result
Could you please post your query for my reference what you have tried?
Oct 31 '07 #2
mwasif
802 Expert 512MB
The following query will list down the users with highest votes on top.
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM table ORDER BY Votes DESC
What do you mean by ROUND?
Nov 1 '07 #3
amitpatel66
2,367 Expert 2GB
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. select r.entry,g.user,g.mvotes FROM
  3. (select user,max(votes) mvotes rom table_name group by user) g,table_name r
  4. WHERE r.user = g.user
  5. AND r.votes = g.mvotes
  6.  
  7.  
Nov 2 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ralph Freshour | last post by:
I have a question about the following PHP script - I got it off a web site tutorial on how to count users logged into your site - my question is the $PHP_SELF variable - it writes the name of the...
4
by: Florian | last post by:
Hi, I have a table that contains log data, usually around a million records. The table has about 10 columns with various attributes of the logged data, nothing special. We're using SQL Server...
5
by: Fred Zuckerman | last post by:
Can someone explain the difference between these 2 queries? "Select Distinct id, account, lastname, firstname from table1" and "Select DistinctRow id, account, lastname, firstname from table1" ...
2
by: Dixie | last post by:
I have a table of records, many of which are repeated or differ in 4 of the 6 fields only. I want to show only those records on a continuous form that are unique in the first 2 fields. That is as...
2
by: vvyshak | last post by:
Hi all... I have a table in which some columns has distinct values and some has duplicates..i wan to select all the columns with distinct values....no problem if rows has null value in it....i...
4
by: dubing | last post by:
Hello everyone, I've tried both DISTINCT or DISTINCTROW in the following query in a PHP script. But the results still contain duplicate records as show below. DISTINCT works fine on single...
6
by: issac | last post by:
Hi folks Im trying to do a simple query involving the distinct keyword and an access 2000 db, but have been frittering with it for amost and hour and a half and I cant make it work. This is...
4
by: burgensteen | last post by:
Hi all, New to this forum, so to start 'A big hello to you all'. My question: I have a drop down menu that is created from the username in my database but is distinct: ...
4
by: omnittha | last post by:
I would like to pull unique records of a SINGLE column but not the other related columns. When I use DISTINCT, it pulls up all the records which are unique across the columns. Here is the code.......
8
by: penfold33 | last post by:
Hi I need to generate a CSV of names and address from a table and I would like only one result (it doesn't matter which) per distinct email address. If possible, they also need to be ordered by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.