Re: To get a Table or View like a Calendar with dates

From: Csanyi Pal <csanyipal(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: To get a Table or View like a Calendar with dates
Date: 2012-08-15 20:07:46
Message-ID: 87wr0zor59.fsf@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi Kevin,

"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:

> Csanyi Pal <csanyipal(at)gmail(dot)com> wrote:
>
>> The database should store the data like dates of the beginning and
>> the end of the school year, holidays, non school days, various
>> events, etc.
>>
>> I want to get a Table or a View which I can use as a School
>> Calendar with school days, and non school days too, and much more.
>>
>> I have created Tables with dates of the beginning date and the end
>> date of the school year.
>>
>> I have Table with dates of holidays and/or non school days in the
>> school year too.
>>
>> Can I create a Table or a View from these Tables to get such a
>> school calendar?
>
> Yes, it sounds like the set of tables you describe could support a
> great many useful queries, and you could encapsulate these in views
> to make them easier to use.

I have amongs other two tables:
felevek_kezdetei_1_8 and
felev1_vege_tan_nap_1_8

iskolanaptar_201213=# set search_path to félévek_negyedévek;
SET

The first table contains the ordinal number of the semester (1 or 2) and
the start dates of the same:

iskolanaptar_201213=# select * from felevek_kezdetei_1_8;
felev1v2 | datum
----------+------------
1 | 2012-09-03
2 | 2013-01-15
(2 rows)

The second table contains the end date of the first semester and the
number of the days in this semester:

iskolanaptar_201213=# select * from felev1_vege_tan_nap_1_8;
datum | ennyi_tan_nap
------------+---------------
2012-12-21 | 78
(1 row)

So I'm trying as a beginning to create the 'felev_1_napjai' view that
should display only the first and the end date of the first semester:

iskolanaptar_201213=# create or replace view felev_1_napjai as select
datum from felevek_kezdetei_1_8, felev1_vege_tan_nap_1_8 where
felevek_kezdetei_1_8.felev1v2 = '1';
ERROR: column reference "datum" is ambiguous
LINE 1: create or replace view felev_1_napjai as select datum from f
^
> Are you having some problem doing so? What have you tried? What
> did you expect to happen? What happened instead?

As you can see above I get error message.

If I success in this I shall modify this view so so I get a view of
dates between the start and the end date of the first semester. I shall
to use the generate_series somehow, but sofar I have no success.

--
Regards from Pal

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Kevin Grittner 2012-08-15 21:08:38 Re: To get a Table or View like a Calendar with dates
Previous Message Michael Wood 2012-08-14 06:25:05 Re: how to get desired html format output?