Method 1. Use pivot table Method 2. Left join to many sub-queries; each sub-query is for one storeId group by ItemId.