Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 227356327F4 for ; Thu, 25 Jun 2009 14:37:54 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 92112-10 for ; Thu, 25 Jun 2009 14:37:49 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f226.google.com (mail-bw0-f226.google.com [209.85.218.226]) by mail.postgresql.org (Postfix) with ESMTP id B46F063275D for ; Thu, 25 Jun 2009 14:37:50 -0300 (ADT) Received: by bwz26 with SMTP id 26so1742372bwz.19 for ; Thu, 25 Jun 2009 10:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=XdlVmyS2XlBWZuTgYpfj5h99SBFRvrXCbDiQuTQqwgs=; b=BXziOhRZndTjoHh+mFKC01lOAl7hiC4+w2lkJBNg7DN2aGYwJX5P9xOfWkj1VJi2ut 8Ur6mKbX0HOGtv6xmeBbvEZcR8tkxkT0gpFZIhZOxT949UjCn1mDDuQE6GOrh6ICoWpV g/Wd7Qs8mkF7/lUYLcsEQ+PktddfZvzTmUCkA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=TqCmmiRFQjAa74lZKcLo9wp8h7R8wCJQBJzulQ+/9NbPxvCW6DEnI/FZj6lkjuk4L0 pIU7F9BOg8JitQiJT+UKfI0kEiLxTXnUCZmrx4vT1tZYrQ8FjCWx7LpJsJp/4wTAXmnA stYgtDOQ5utc2fleTu2kJGa20eYy2ucPx9piE= MIME-Version: 1.0 Received: by 10.204.124.7 with SMTP id s7mr2705991bkr.105.1245951469166; Thu, 25 Jun 2009 10:37:49 -0700 (PDT) In-Reply-To: <863824.473.qm@web27906.mail.ukl.yahoo.com> References: <863824.473.qm@web27906.mail.ukl.yahoo.com> Date: Thu, 25 Jun 2009 14:37:49 -0300 Message-ID: <690707f60906251037h6d5dd0d5g333a981fef03e38f@mail.gmail.com> Subject: Re: Bucketing Row Data in columns From: Osvaldo Kussama To: James Kitambara Cc: gibsosmat@gmail.com, pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200906/105 X-Sequence-Number: 32710 2009/6/25 James Kitambara : > > Hello Mr. Sandeep Bandela, > > I have gone through your scenario and come up with the following solution. > > SELECT USER_ID, CREATE_TIMESTAMP::DATE, SUM(AMOUNT) > FROM ORDERS > GROUP BY USER_ID, CREATE_TIMESTAMP > ORDER BY USER_ID, CREATE_TIMESTAMP; > > Maybe you need to do little modification on the query to get what you want. > Contrib tablefunc/crosstab function may help you. http://www.postgresql.org/docs/current/interactive/tablefunc.html Osvaldo