I have a table that is a list of every item in the system. There is a column that says whether the item is a default item or not. In the query I'm going through the items and selecting ones that have a MSDS associated with them, however my query returns multiple items for the same item number because multiple records exist for the item.
So what I want to do is limit the results to just default items. Normally I would just do WHERE itemsrc.itemsrc_default, however not every item has been setup with a default record, so what I want to do is go through the table and if a default record exists for an item than give priority to that item, otherwise if no default record exists, return the first record for that item number.
I'm not sure if I would do this as a subquery in the WHERE clause of the main query or if I should make function that checks for defaults.