I have two tables, one stores a record for each item each time it is used. The second holds the main item list and has a record for each user. So an item could be in the table multiple times. I see now this needs to better normalized.
But is there a way to make the following query return one record instead of counting 2 which is currently how many of a particular item are in the main table ([grocery_Items-rename])
Here is my SQL statement
TIA
Doug
DougP
But is there a way to make the following query return one record instead of counting 2 which is currently how many of a particular item are in the main table ([grocery_Items-rename])
Here is my SQL statement
Code:
Select distinct(i.UPCode), Count(i.UPCode) as TotalUsed ,[Description],
t.[UserName]
from [grocery_Items_Tracking] t inner join [grocery_Items-rename] i on i.UPCode = t.UPCode
Group by i.UPCode,[Description] ,t.UserName
Having t.UserName = 'llh123'
Order by TotalUsed DESC
TIA
Doug
DougP