0

I am looking to create a statement in which I need two columns from the SELECT statement to be distinct.

Here is my current formula below (apologies for the sloppiness).

SELECT     team_id_num,
           source_id_num, 
           engineer,
           status
FROM       report central
GROUP BY   engineer
ORDER BY   team_id_num ASC;

For team_id_num I am wanting to get just one team_id_num (DISTINCT). The tricky part is that there should be a unique source_id_num for each correlating team_id_num by engineer (need to group by engineer because if not, I will not be able to see the team_id_num if another engineer has that team_id_num.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Phil
  • 73
  • 3
  • 9
  • I would like to insert this into a new table to monitor the databases integrity. – Phil Oct 23 '15 at 18:04
  • 3
    perhaps answered here: http://stackoverflow.com/questions/54418/how-do-i-or-can-i-select-distinct-on-multiple-columns – Doon Oct 23 '15 at 18:04
  • It seems you don't know how SQL work. You want to group by engineer. But what do you want to group? Is there a total to sum? A number of rows to count? And you want to get only one team_id_num, but for what reason you get rid of the others? Do you want a random team_id_num for each engineer? – Sergio Internicola Oct 23 '15 at 18:22

0 Answers0