X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A4E4555478 for ; Thu, 24 Feb 2005 15:17:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58625-07 for ; Thu, 24 Feb 2005 15:17:09 +0000 (GMT) Received: from smtp20.kymp.net (smtp20.kymp.net [80.248.96.137]) by svr1.postgresql.org (Postfix) with ESMTP id 96BFF55387 for ; Thu, 24 Feb 2005 15:17:07 +0000 (GMT) Received: from [192.168.16.100] (static-241-66.kymp.net [213.130.241.66]) by smtp20.kymp.net (8.13.3/8.13.3) with SMTP id j1OFHFZi002256 for ; Thu, 24 Feb 2005 17:17:15 +0200 From: Aarni =?iso-8859-1?q?Ruuhim=E4ki?= Reply-To: aarni@kymi.com Organization: KYMI.com To: pgsql-sql@postgresql.org Subject: Read count ? Date: Thu, 24 Feb 2005 17:17:14 +0200 User-Agent: KMail/1.6.2 MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200502241717.14648.aarni@kymi.com> X-Virus-Scanned: by amavisd-new X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200502/305 X-Sequence-Number: 20415 Hi, Could someone please give a hint on how to query the following neatly ? Get news from a news table that belong to a particular account, get segment name from segments table for each news item and read count from read history table that gets a news_id and timestamp insert every time the news is read. Display everything by news count, most read news first ? news_id 4, news_header, segment_name x, read 10 times news_id 2, news_header, segment_name y, read 8 times news_id 1, news_header, segment_name x, read 7 times news_id 3, news_header, segment_name x, read 0 times news_table: news_id, account_id, segment_id, news_header, ... segments_table: segment_id, account_id, segment_name read_history_table: history_id, news_id, timestamp TIA, Aarni -------------- This is a bugfree broadcast to you from **Kmail** on **Fedora Core 2** linux system --------------