Table of Contents

Strukturdaten

wholelist_sd

eine liste aller einrichtungen in allen datenbanken mit id als unique identifier.

select * from (
  select distinct on (id) * from (
    select 'daten' as y,id,bundesland,name,status from strukturdaten where bundesland=4 union
    select '2000' as y,id,bundesland,name,status from struktur2000 where bundesland=4 union
    select '1995' as y,id,bundesland,name,status from struktur1995 where bundesland=4 
  order by y desc) as x)
as y order by bundesland,status,name;

um sicher zu gehen, dass bei verschiedenen namen gleicher id immer der aktuelle name aufscheint, wird der name der datenbank als sort-kriterium benutzt

next_sd

die nächste id zu einem aktuellen datensatz in der reihung bundesland,status,name

select * from (
  select distinct on (id) * from (
    select 'daten' as y,id,bundesland,name,status from strukturdaten union
    select '2000' as y,id,bundesland,name,status from struktur2000 union
    select '1995' as y,id,bundesland,name,status from struktur1995
  order by y desc) as x)
as z where 
  bundesland<4 OR (
    bundesland=4 AND (
      status<4 OR (
        status=4 AND name<'Volkshochschule Freistadt'
      ) 
    ) 
  )
order by bundesland desc,status desc,name desc limit 1;
 
kb/templateengine/sql.txt · Last modified: 2006/02/01 23:28