Issue #3195178 by mstrelan, Lendude, Graber, tobiberlin, texas-bronius: Views table format sorting + distinct results in a SQL error on some db engines (cherry picked from commit 4e5f54f4)