Hi I have two tables in a sql db. Table one has the the following fields:rim, size, code, design and brandTable two:code, ddate and dpriceI need to find out the number of distinct dates for each brand and use those dates in this query:select size, a.code, design, brand,sum( case when convert(varchar,Ddates,112) = 20060110 then dprice else 0 end ),sum( case when convert(varchar,Ddates,112) = 20060105 then dprice else 0 end ),sum( case when convert(varchar,Ddates,112) = 20061112 then dprice else 0 end )from brand_size a left outer join brand_price bon a.code = b.codegroup by size, a.code, design, brand
The problem is that I don't know the number of dates each brand can have. Brand X can have 5, brand Y maybe 3 and brand Z maybe 1.My results should be something like this Brand 1 Brand 2 etc...Size, Code, Design, Date1 date2 Date3 etc.. Date1 date2 Date3 etc..
Kind RegardsNever Argue with an idiot. They drag you down to their level and beat you with experience.