Advertisement
Guest User

rec_descriptor as crosstab()

a guest
Apr 10th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE VIEW metabib.rec_descriptor AS
  2. SELECT id
  3.      , id AS record
  4.      , item_type
  5.      , item_form
  6.      , bib_level
  7.      , control_type
  8.      , char_encoding
  9.      , enc_level
  10.      , audience
  11.      , lit_form
  12.      , type_mat
  13.      , cat_form
  14.      , pub_status
  15.      , item_lang
  16.      , vr_format
  17.      , date1
  18.      , date2
  19. FROM crosstab(
  20. 'SELECT v.source AS id,
  21.    m.attr,
  22.    m.value
  23.   FROM metabib.full_attr_id_map m
  24.   JOIN metabib.record_attr_vector_list v ON m.id = ANY (v.vlist)
  25.  ORDER BY v.source'
  26.  
  27.        ,$$VALUES ('item_type'), ('item_form'), ('bib_level'), ('control_type'), ('char_encoding'), ('enc_level'), ('audience'), ('lit_form'), ('type_mat'), ('cat_form'), ('pub_status'), ('item_lang'), ('vr_format'), ('date1'), ('date2')$$
  28.  ) AS ct (
  29.    id bigint
  30.      , item_type text
  31.      , item_form text
  32.      , bib_level text
  33.      , control_type text
  34.      , char_encoding text
  35.      , enc_level text
  36.      , audience text
  37.      , lit_form text
  38.      , type_mat text
  39.      , cat_form text
  40.      , pub_status text
  41.      , item_lang text
  42.      , vr_format text
  43.      , date1 text
  44.      , date2 text
  45. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement