Search code examples
sql-serverdata-bindingdatalist

How to show data in a random order using SQL query


This is the SQL query that is binding into my DataList. Can you please tell me how to return the data in a random order?

SELECT
   CONVERT(varchar(6), a.lastdate, 6) as lastdate, * 
FROM
   alz_jobpost AS a 
INNER JOIN
   (SELECT * 
    FROM alzome_SuperAdmin AS b 
    INNER JOIN alzome_Renewal AS c ON b.S_id = c.supid 
    WHERE c.product = 'HI-TOUCH' AND c.Payed = 1) AS aa ON a.oid=aa.businessid 
WHERE
   a.status = 1 
   AND a.lastdate > GETDATE() 
ORDER BY 
   a.startdate DESC

Solution

  • To get your results in a random order you can change the:

    ORDER BY a.startdate DESC

    to something like:

    ORDER BY NEWID()