How to Display Unique Values from database using db_select in Drupal
Try

$query = db_select('webform_submitted_data', 'u');
$query-&gt;fields('u', array('sid','nid')); $query-&gt;condition('nid','49','=');
$results =$query-&gt;distinct()-&gt;execute();


Api info about unique