Thanks so much Zaela_S, that's exactly what I was looking for .. It works perfectly.
I was trying to figure it out by myself but I am still in the process of learning the more complex SQL functions, and as you said the way the table is set up is a pita...I now understand that the use of temp table was the key here...
Thanks again for your help