Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id EE2A5B5DBE0 for ; Tue, 16 Aug 2011 02:19:10 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 36434-01 for ; Tue, 16 Aug 2011 05:19:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from forward6.mail.yandex.net (forward6.mail.yandex.net [77.88.60.125]) by mail.postgresql.org (Postfix) with ESMTP id A5965B5D803 for ; Tue, 16 Aug 2011 02:19:03 -0300 (ADT) Received: from web94.yandex.ru (web94.yandex.ru [77.88.60.18]) by forward6.mail.yandex.net (Yandex) with ESMTP id 356E3F8135A; Tue, 16 Aug 2011 09:19:01 +0400 (MSD) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1313471941; bh=lOD++4JT7zsdPbAlQ9k/MajqE0XgOgp4Nu8Da1jhyJA=; h=From:To:In-Reply-To:References:Subject:MIME-Version:Message-Id: Date:Content-Transfer-Encoding:Content-Type; b=FcnFX92nMuZogIdE5MiBeP9TfqjROExjfVFw/PvEGgDpsv1l1cxIp+WpKRm41SuXN MxR88YCGxz1INWdSME4O4FVkllvTmzVTVQwuwH6+cE1OXyFyaN55sGFE324TruW4I1 Y/5tb5UAtDjUNCnjXmsRG/uzAtPWsY8MQ6qnLyvw= Received: from localhost (localhost.localdomain [127.0.0.1]) by web94.yandex.ru (Yandex) with ESMTP id 1F8C919C01A2; Tue, 16 Aug 2011 09:19:01 +0400 (MSD) X-Yandex-Spam: 1 Received: from [2.94.187.195] ([2.94.187.195]) by web94.yandex.ru with HTTP; Tue, 16 Aug 2011 09:19:00 +0400 From: msi77 To: Yuan HOng ,pgsql-sql@postgresql.org In-Reply-To: References: Subject: Re: F_TABLE_NUMBER_RANGE equivalent in Postgresql MIME-Version: 1.0 Message-Id: <964111313471940@web94.yandex.ru> Date: Tue, 16 Aug 2011 09:19:00 +0400 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.799 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201108/54 X-Sequence-Number: 35722 Are you sure that dbo.F_TABLE_NUMBER_RANGE is in SQL Server? I suppose that this is UDF written by user. 16.08.2011, 08:53, "Yuan HOng" : > Hi, > > With MS-SQL sever, there is a built-in utility function > dbo.F_TABLE_NUMBER_RANGE which generates a list of number between the > given range. For example: > > select dbo.F_TABLE_NUMBER_RANGE(1, 5) will return: > > number > ----------- > 1 > 2 > 3 > 4 > 5 > > This is extremely convenient for generating consecutive dates. For > example, I want to find out the daily sales information and if on some > day there is no sales, the query should return 0 instead of a missing > date. > > In this case it is necessary to first create a list of consecutive > dates and then left join to some fact table. > > With the range function I can simply write something like > > select start_date + interval number > from dbo.F_TABLE_NUMBER_RANGE(1, number_of_days) > > How does one accomplish such task with Postgresql? > > -- > Hong Yuan > > 大管家网上建材超市 > 装修装潢建材一站式购物 > http://www.homemaster.cn > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql