On Wed, Dec 05, 2007 at 11:43:08AM +0000, Steve Grey <stevegrey78@xxxxxxxxx> wrote a message of 153 lines which said: > First work out the maximum number of times each value of X will occur in the > table A better solution, when you do not know this maximum number, is CREATE AGGREGATE (http://www.postgresql.org/docs/8.1/interactive/xaggr.html) See details : http://www.bortzmeyer.org/agregats-postgresql.html (Yes, it is in french but the SQL examples are in english, variable names included, so they still can be useful for the OP). ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq