Search code examples
sqlaspdotnetstorefront

Using SQL Order statement to show last 60 days on record


Have a Stored Procedure with a SQL db that returns all values of products. At the end of the stored proc the order is shown as

ORDER BY pf.rownum 

I have tried to include this line within the stored procedure to show the last 60 days of products

where
CreatedOn >=dateadd(day,datediff(day,0,GetDate())- 60,0)

But I think that the products created on date are outside of the date scope. Is there a way of including the date selection within the ORDER BY line and removing this CreatedOn value?

This is within AspDotNetStoreFront

Thanks!


Solution

  • Are you asking how to order by two columns?
    If yes then code below should do it.

    ORDER BY pf.rownum ASC, pf.CreatedOn DESC