• If the query needs to have dynamic headers you probably want to acquaint yourself with Jeff Moden's work on cross tabs and pivots.
    CrossTabs and Pivots, Part 2

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?