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

Query (or VBA) to sort data by category

25
Hello!

I have data that consist of the follow as an example: Team name, player name and the score for that player. in the same time i have a total for that team in the dataset so it looks like this:

team player score

red John 5
red Mike 7
red Josh 4
red total 16
green Ron 4
green Ryan 7
green Eddie 6
green total 17

so if that is my dataset, i would like to sort it by team's total score, however keeping all the players with that team. As a result i would have all the players listed from team with most points on top and then the total for that team, following by the 2nd team's players and then 2nd team total, and so on...
Any Ideas?? I really appreciate any suggestions, Thanks.
Jul 27 '07 #1
2 1873
missinglinq
3,532 Expert 2GB
You have inadvertently posted your question in the Articles section rather than the Forum section. I have moved it to the Forum for you.

Linq ;0)>
Jul 27 '07 #2
mlcampeau
296 Expert 100+
Hello!

I have data that consist of the follow as an example: Team name, player name and the score for that player. in the same time i have a total for that team in the dataset so it looks like this:

team player score

red John 5
red Mike 7
red Josh 4
red total 16
green Ron 4
green Ryan 7
green Eddie 6
green total 17

so if that is my dataset, i would like to sort it by team's total score, however keeping all the players with that team. As a result i would have all the players listed from team with most points on top and then the total for that team, following by the 2nd team's players and then 2nd team total, and so on...
Any Ideas?? I really appreciate any suggestions, Thanks.
If you put this line in your SQL:
ORDER BY [TeamName], [Score]
And in design view of your query, under [Score], change the sort from Ascending to Descending.

That should give you a result like:

team player score

green total 17
green Ryan 7
green Eddie 6
green Ron 4
red total 16
red Mike 7
red John 5
red Josh 4

I'm not sure exactly how you would get the total to show up at the end of the list. I'm a little confused actually why the total would be stored in a table because it is a calculated value. It would be better if you calculated it in your query, which would create a separate column for it, or on your report.

If you create the calculated value in your query rather than store it in a table, you can use
ORDER BY [TotalScore],[Team]
where [TotalScore] is sorted in Descending order and it should give you a result like this:


team player score total

green Ryan 7 17
green Eddie 6 17
green Ron 4 17
red Mike 7 16
red John 5 16
red Josh 4 16
Jul 27 '07 #3

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

Similar topics

1
by: dawnunder | last post by:
eg. Someone fills out 3 fields. (There will be more but this is just to give you an idea) 1. Country? 2. State? 3. City I want this script to generate a web page and list the people by
2
by: Willem-Jan Selen | last post by:
Is it possible so sort data from a table based on the count results? I have the following <% set rs = db.execute("Select * from tbleventinfo order by ename") while not rs.EOF tmp = rs("eid")...
0
by: tsirman | last post by:
hello i have the above code and i can't sort my data in the second column. if someone did not understood i want to say that i have splitted my data in two columns so now i want these data to be...
2
by: mael.iosa | last post by:
Hi, I'm new to this group and fairly new to Access. I have a bunch of data, and after several other queries, I generate the following query which has two fields: Bin, Time 20 3.5 20 3.9 20...
1
by: Luqman | last post by:
I have created a Insert Query in Sql Data Source using Oracle Database, with the parameters, and its connected with DetailView Control. When I try to Insert through DetailView Control, Illegal...
3
by: prasa | last post by:
what are the coad snippet for sort data in a data grid after retriving from the SQL db.. thanks for answering if so regards...prs
0
by: Alexandre Brisebois | last post by:
I have been trying to use Linq o SQL to query an XML data column I currently have in my DB, but it seems that Linq to SQL sees a typed xml column as an XElement, I don't want to get the full...
18
by: freeflyer30339 | last post by:
I receive data from another program which I am unable to change. I am trying to create an VBA SQL query in Access '03 that will convert a field that has a date which is in an unrecognizable format....
4
by: thecheyenne | last post by:
Dear All! I have a query that holds test results for my students; each test is either a listening-test, reading-test, speaking-test or writing-test. All results are in % and already calculated by...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?

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.