Views Custom Join change the 'on' condition We are using Drupal commerce and have a report in views using commerce_line_item as the base. We need to be able to split the quantities up into multiple rows. So if a line item has a qty of 5 there should be 5 rows. I am trying to implement this:

https://stackoverflow.com/questions/22291814/mysql-return-result-by-quantity-per-row

I am adding a join in hook_views_query_alter but there does not appear to be a way of changing the join condition from = to &lt;=.

LEFT JOIN {line_items_tally} line_items_tally ON commerce_line_item.quantity = line_items_tally.n

needs to be 

LEFT JOIN {line_items_tally} line_items_tally ON commerce_line_item.quantity &lt;= line_items_tally.n

Is there any way of doing that?
I ended up using hook_query_alter rather than hook_views_query_alter

/**
 * Implements hook_query_alter().
 */
function custom_query_alter(QueryAlterableInterface $query) {
  if ($query-&gt;hasTag('line_itmes_qty')) {
    $query-&gt;join('line_items_tally', 't', 't.n &lt;= commerce_line_item.quantity');
  }
}