creating view - conditional testing in construct

Поиск
Список
Период
Сортировка
От richard terry
Тема creating view - conditional testing in construct
Дата
Msg-id 200910231021.35766.rterry@pacific.net.au
обсуждение исходный текст
Ответы Re: creating view - conditional testing in construct  (Nathaniel Trellice <naptrel@yahoo.co.uk>)
Список pgsql-novice
Hi all,

I'm struggling to find the syntax to create a view in this situation.

I'm joining a table to an existing view


create vwMyView as

       vworganisationsemployees.fk_organisation,
        vworganisationsemployees.fk_branch,
        vworganisationsemployees.fk_employee,
        vworganisationsemployees.fk_person,
         vworganisationsemployees.fk_address,
** I want all these fields to end up as as field called, say summary
    (vworganisationsemployees.title ||' '::text) ||
        (vworganisationsemployees.firstname ||' '::text)  ||
        (vworganisationsemployees.surname ||'( '::text)  ||
        (vworganisationsemployees.occupation ||') '::text) ||
        (vworganisationsemployees.organisation ||' '::text) ||
        (vworganisationsemployees.branch ||' '::text)  as summary

so far so good, as all the employees of the organisations will always contain
the data, however in the vwOrganisationsEmployees, some rows will not contain
the address of the branch  ie fk_address is null, and the street and suburb
fields are null.

So at this point in the query it works ok, but I want also to add the address
of the branch into the summary field, and in some records there is no
fk_address and hence no street or suburb.

so I want to be able to conditionally test if fk_address is null, if it is,
then keep adding the street, suburb, postcode to the field which ends up being
called summary.

Any help appreciated.

Regards

Richard

В списке pgsql-novice по дате отправления:

Предыдущее
От: Nathaniel Trellice
Дата:
Сообщение: Asynchronous commands
Следующее
От: vikas vashista
Дата:
Сообщение: Re: user defined data type