Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi, I need to display random with distinct records eg.65 Pencil66 Pencil68 Eraser69 PenOutput: 66 Pencil68 Eraser69 PenOr 65 Pencil68 Eraser69 PenCan someone please kindly assist. Thanks.
James K
Master Smack Fu Yak Hacker
3873 Posts
Posted - 2013-05-31 : 17:20:13
One of these?
SELECT MAX(NumberColumn),PencilColumn FROM TblGROUP BY PencilColumn;;WITH cte AS( SELECT *,ROW_NUMBER() OVER (PARTITION BY PencilColumn ORDER BY NEWID()) AS OrderingId FROM Tbl)SELECT NumberColumn, PencilColumn FROM cte WHERE OrderingId = 1;