I am trying to query blog posts on my website using a data source web part.
Using a SQL where clause in my data source I am doing the following to grab by category from the query string:
('{%ToInt(QueryString.categoryid, "")#%}' = 0 AND '{%categoryname%}'='') OR (DocumentID IN (SELECT DocumentID FROM CMS_DocumentCategory WHERE CategoryID = {% ToInt(QueryString.categoryid) #%}))
From there I want to order by BlogPostDate in descending order, so I go into my order by clause in the data source web part and add the following:
ORDER BY BlogPostDate DESC
I am getting an error every single time stating it is an invalid SQL query. How can I make this query work with the where and the order by clause?
Hi Eric,
Is this happening because you are putting an entire order by statement in the order by field, e.g. ORDER BY BlogPostDate DESC
You shouldn't need the ORDER BY part, try again with just BlogPostDate DESC
BlogPostDate DESC
Please, sign in to be able to submit a new answer.