I have a table that is poorly designed and I want to replace it with a couple of other tables, but first I have to extract data.
Here are some of the columns of the table:
Location_id, Item_id, Location, Description
The Item_id refers to objects (from another table) that are stored in a location in the location table (location being a room number in a building).
The way it is now, there are multiple repeated values of Location and Description in the table.
I would like to extract Location, Description from that table into a view but I also need to have the view retain one of the Location_id values (it's not important which one, I could use the MINIMUM), but so far I haven't been able to do that.
I can do this: select distinct location, description but how do I add the minimum location_id into my result set?
Should I be using group by instead of distinct?
Thanks for your help.