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

Stuck on simple ASP & SQL query.

Hello,

I am stuck on what is probably a very easy select query.
The query is:

Select Count(*), Distinct PID, ID, Name
From Table 1
Group By PID

I get:

| Count | PID | ID | Name |
--------------------------------------------------------
| 130 | GGT | 50 | Andy |
| 60 | AAM | 51 | Graeme |
| 360 | RGG | 52 | John |

Now, there are 130 records with a PID of GGT. Why has "Andy" been returned
in the row? There is a William in the row at the end of the alphabet. I
want to sort INSIDE THE COUNT on Name Desc, but when I use Order By Name
Desc, it ignores it. Very hard!!!

Any help is greatly appreciated!

Gary.
PS - Sorry if I have no explained this properly - very hard.
Jul 19 '05 #1
1 1303
Please don't multi-post. Answering this question in a SQL Server group.
Follow up there...

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Gary W" <ga**@garywhittle.co.uk> wrote in message
news:c3*******************@news.demon.co.uk...
Hello,

I am stuck on what is probably a very easy select query.
The query is:

Select Count(*), Distinct PID, ID, Name
From Table 1
Group By PID

I get:

| Count | PID | ID | Name |
--------------------------------------------------------
| 130 | GGT | 50 | Andy |
| 60 | AAM | 51 | Graeme |
| 360 | RGG | 52 | John |

Now, there are 130 records with a PID of GGT. Why has "Andy" been returned in the row? There is a William in the row at the end of the alphabet. I
want to sort INSIDE THE COUNT on Name Desc, but when I use Order By Name
Desc, it ignores it. Very hard!!!

Any help is greatly appreciated!

Gary.
PS - Sorry if I have no explained this properly - very hard.

Jul 19 '05 #2

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

Similar topics

12
by: ~~~ .NET Ed ~~~ | last post by:
Hi, I have a standalone XML file (with the appropriate xml document header) that works fine when I load it using XmlDocument. I can have child elements like this without problems: ...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
3
by: Marina | last post by:
Ok here's my problem.... I have a custom dialog box that allows the user to enter information to run a Parameter Query. This works GREAT, but I need that query to show as a form, not just the...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
1
by: colleen1980 | last post by:
When I run my query it stuck is it possible that i can debug it SELECT TOP 1 tblCredits.OPR, Min(tbl_CRCDollars.SumOfAMOUNT) AS MinOfSumOfAMOUNT, Avg(tblCredits.Credit) AS AvgOfCredit,...
1
by: adriann | last post by:
Hi, I have a page that displays Mysql query results in either "simple" or "detailed" format. The directive to display in the desired format is obtained by looking at the value of a Session variable....
4
by: billb | last post by:
I installed a perl extension for PHP to use some perl inside my php primarily because I have perl working with oracle and not php and oracle. So I want to use my old perl scripts, and use the...
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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.