You are here: Re: Need More SQL Query NewID Help « MsSQL Server « IT news, forums, messages
Re: Need More SQL Query NewID Help

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация