I'm trying to limit row items to 1 as per the GROUP BY result in Views 3.x, below is the view which I've created but I'm missing the key part from that, below is the exported code of my view.
$view = new view();
$view->name = 'position';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Position';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Position';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['grouping'] = array(
0 => array(
'field' => 'field_home_page_anchor_position',
'rendered' => 1,
'rendered_strip' => 0,
),
);
$handler->display->display_options['style_options']['columns'] = array(
'title' => 'title',
'field_home_page_anchor_position' => 'field_home_page_anchor_position',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
'title' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
'field_home_page_anchor_position' => array(
'sortable' => 0,
'default_sort_order' => 'asc',
'align' => '',
'separator' => '',
'empty_column' => 0,
),
);
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Field: Content: Home Page Anchor Position */
$handler->display->display_options['fields']['field_home_page_anchor_position']['id'] = 'field_home_page_anchor_position';
$handler->display->display_options['fields']['field_home_page_anchor_position']['table'] = 'field_data_field_home_page_anchor_position';
$handler->display->display_options['fields']['field_home_page_anchor_position']['field'] = 'field_home_page_anchor_position';
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Sort criterion: Content: Home Page Anchor Position (field_home_page_anchor_position) */
$handler->display->display_options['sorts']['field_home_page_anchor_position_value']['id'] = 'field_home_page_anchor_position_value';
$handler->display->display_options['sorts']['field_home_page_anchor_position_value']['table'] = 'field_data_field_home_page_anchor_position';
$handler->display->display_options['sorts']['field_home_page_anchor_position_value']['field'] = 'field_home_page_anchor_position_value';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'news_story' => 'news_story',
);
/* Filter criterion: Content: Home Page Anchor Position (field_home_page_anchor_position) */
$handler->display->display_options['filters']['field_home_page_anchor_position_value']['id'] = 'field_home_page_anchor_position_value';
$handler->display->display_options['filters']['field_home_page_anchor_position_value']['table'] = 'field_data_field_home_page_anchor_position';
$handler->display->display_options['filters']['field_home_page_anchor_position_value']['field'] = 'field_home_page_anchor_position_value';
$handler->display->display_options['filters']['field_home_page_anchor_position_value']['operator'] = 'not empty';
$handler->display->display_options['filters']['field_home_page_anchor_position_value']['value'] = array(
'min' => '',
'max' => '',
'value' => '',
);
/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');
$translatables['position'] = array(
t('Master'),
t('Position'),
t('more'),
t('Apply'),
t('Reset'),
t('Sort by'),
t('Asc'),
t('Desc'),
t('Home Page Anchor Position'),
t('Block'),
);
SQL query generated by View is:
SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created, field_data_field_home_page_anchor_position.field_home_page_anchor_position_value AS field_data_field_home_page_anchor_position_field_home_page_a, 'node' AS field_data_field_home_page_anchor_position_node_entity_type
FROM
{node} node
LEFT JOIN {field_data_field_home_page_anchor_position} field_data_field_home_page_anchor_position ON node.nid = field_data_field_home_page_anchor_position.entity_id AND (field_data_field_home_page_anchor_position.entity_type = 'node' AND field_data_field_home_page_anchor_position.deleted = '0')
WHERE (( (node.status = '1') AND (node.type IN ('news_story')) AND (field_data_field_home_page_anchor_position.field_home_page_anchor_position_value IS NOT NULL ) ))
ORDER BY node_created DESC, field_data_field_home_page_anchor_position_field_home_page_a ASC