Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Top 10 Query 1

Status
Not open for further replies.

georgesOne

Technical User
Joined
Jul 2, 2004
Messages
176
Location
JP
Hi All:

How do I get the top 10 records from the following QUERY1 with a single query:

SELECT tbl_Form1.RName, Count(tbl_Form1.RName) AS [Number], 1 AS [Position]
FROM tbl_Form1
GROUP BY tbl_Form1.RtName
HAVING (Count(tbl_Form1.RName))>1
ORDER BY Count(tbl_Form1.RName) DESC

I tried to modify QUERY1 to

SELECT TOP 10 tbl_Form1.RName, Count(tbl_Form1.RName) AS [Number], 1 AS [Position]
FROM tbl_Form1
GROUP BY tbl_Form1.RtName
HAVING (Count(tbl_Form1.RName))>1
ORDER BY Count(tbl_Form1.RName) DESC

but I get the same result as with QUERY1.

If I use the following QUERY2

SELECT TOP 10 Query1.RName, Query1.Number, 1 AS [Position] FROM Query1;

I get the desired result.

Any comments?

Thanks, georges
 

How about...
Code:
SELECT TOP 10 RName, Number, Position FROM 
(SELECT tbl_Form1.RName, Count(tbl_Form1.RName) AS [Number], 1 AS [Position]
FROM tbl_Form1
GROUP BY tbl_Form1.RtName
HAVING (Count(tbl_Form1.RName))>1
ORDER BY Count(tbl_Form1.RName) DESC)


Randy
 
That worked... thans a lot.
georges
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top