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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve random records! 1

Status
Not open for further replies.

JojoKa

Technical User
Mar 28, 2006
18
US
Hi,
I am trying to run this query but I am getting an error message.

Code:
SELECT DISTINCT tbl.PROVID, tbl.[PROV NAME], tbl.SPECIALTY,tbl.[dt], top 25 ([tbl].[ID]) AS New
FROM tbl INNER JOIN tbl1 ON tbl.dt Not like tbl1.dt
ORDER BY tbl.[ID];

Error:
Syntax error(missing Operator) in query expression 'top 25([tbl].[ID])

What I am trying to do is retrieve 25 records randomly from Table (tbl) where the date field (dt) Does not equal the field (dt) in tbl1.

thanks in advance.

Joseph
 
something like this ?
SELECT DISTINCT TOP 25 PROVID, [PROV NAME], SPECIALTY, dt, ID
FROM tbl
WHERE dt Not In (SELECT dt FROM tbl1)
ORDER BY Rnd([ID]);

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks soooo much. You deserve a star.
Joseph
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top