Posted by Erland Sommarskog on 07/07/06 22:09
Paradyse (support@paradysed.com) writes:
> Excuse my ignorance because I don't do advance db related programming,
> but have no other choice at the moment. My experience is limited to
> simple queries.
>
> I need to have the following query display the recordset in random order
> based on RecordID (unique key) if possible. I tried the ORDER BY NewID()
> at the end and it generated an error (ORDER BY items must appear in the
> select list if SELECT DISTINCT is specified.) I guess because of the sub
> query. I would also like for the recordset to display a different 10
> records on each hit to the page, not just the same 10 records in random
> order. I wasn't sure if the SELECT commands I have in place are
> sufficient for this task.
Hugo has already asked why you have the DISTINCT there. Have you tried
simply to remove it?
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|