Ken Tanzer wrote > It's probably way more detail than you want, but I've attached the table > structure and pasted in a quarterly report that the query above was taken > from in case you have any pointers or are simply curious. Is this a quarterly report because that is how long it takes to run? On a smaller scale I've written queries like this. I enrolled in a university database design course shortly thereafter... I would suggest considering how to use functions to encapsulate some of the "medical code collecting" logic. And consider WITH/CTE constructs as well, like I used in my last message, to effectively create temporary named tables for different parts of the query. Might want to move the whole thing into function and pass in the various parameters - namely the date range - instead of hard-coding the values into the view. Those thoughts aside I've done my own share of "write-once, read never" queries and if the performance meets your needs and the maintenance burden is acceptable then sometimes you just leave this in place until someone more knowledgeable (like a future you probably) comes back and decides to toss and rewrite it. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Why-does-this-array-query-fail-tp5771165p5771367.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general