I have a View and it's based on a query and I'd like to modify the query that it is based on. What is the best way to do this?
More specifically, the query generated by Views is like this:
SELECT blah, blah, field-repeating-date, field-startdate, blah blah
FROM etc. etc.
WHERE this, that and the other
ORDER BY field-repeating-date ASC, field-startdate ASC
and I'd like the query to be:
SELECT blah, blah, IFNULL(field-repeating-date, field-startdate) AS thedate, blah blah
FROM etc. etc.
WHERE this, that and the other
ORDER BY thedate
in order to be able to mix the two date fields and have them sort properly. The modified query does what I want when entered through phpMyAdmin.
I'm using Drupal 7 with Views 3.
Edit: I did find a solution, but I can't post an answer for another 3 hours because I do not have a reputation here.