Vladut Vladut - 4 months ago 6
SQL Question

How read multiple column but with DISTINCT value from one column?

Hi i have a table like this:

ID OrderID Date Name Engineer
3870 12302 2016-07-19 11:29:30.547 Popescu Bogdan Yes
4459 12302 2016-07-25 13:02:52.657 Popescu Bogdan Yes
3868 12302 2016-07-19 11:26:36.593 Popescu Bogdan Yes
3869 12302 2016-07-19 11:27:05.797 Popescu Bogdan Yes
4127 12302 2016-07-20 12:10:56.527 maria madalina Yes
4483 12302 2016-07-25 14:01:31.147 andrei vasile Yes
4538 12302 2016-07-25 18:58:34.007 vasilica vrabie Yes


I want to get Date, Name and Enginner but with DISTINCT NAME. I want just Popescu, maria, Adnrei, Vasilica with Date, Name and Egineer

Thanks

Answer

You can try to use:

select DISTINCT NAME, [Date], Enginner 
from myTable

Also you can try

select NAME, [Date], Engineer from myTable where
ID in (Select max(ID) FROM myTable group by Name)

enter image description here