Ticket #1906: Trac_1906.sql

File Trac_1906.sql, 1.6 KB (added by Benjamin Haag, 7 years ago)

Dataview SQL

Line 
1-- ============================================================
2-- taxonomy_regulation_lookup
3-- ============================================================
4SELECT
5 trr.taxonomy_regulation_id AS value_member,
6(ISNULL(g.state, 'Country-wide')) + ', ' + g.country + ': ' + trr.regulation_type_code + ', ' + trr.regulation_level AS display_member
7
8 --ISNULL(g.state, 'Country-wide)') + ', ' + g.country + ': ' + trr.regulation_type_code + ', ' + trr.regulation_level AS display_member
9 FROM
10 taxonomy_ref_regulation trr
11 INNER JOIN
12 geo g
13 ON
14 trr.geography_id = g.geono
15WHERE
16 trr.regulation_level IS NOT NULL
17AND
18 ((trr.created_date > COALESCE(:createddate, '1753-01-01'))
19 OR (trr.modified_date > COALESCE(:modifieddate, '1753-01-01'))
20 OR (trr.taxonomy_regulation_id IN (:valuemember))
21 OR (trr.taxonomy_regulation_id BETWEEN :startpkey AND :stoppkey)
22 )
23
24-- ============================================================
25-- get_taxonomy_regulation_map
26-- ============================================================
27SELECT trm.taxonomy_regulation_map_id
28 ,taxonomy_family_id
29 ,taxonomy_genus_id
30 ,taxonomy_species_id
31 ,taxonomy_regulation_id
32 ,note
33 ,created_date
34 ,created_by
35 ,modified_date
36 ,modified_by
37 ,owned_date
38 ,owned_by
39 FROM gringlobal.dbo.taxonomy_regulation_map trm
40 INNER JOIN
41 (SELECT
42 taxonomy_regulation_map_id
43 FROM
44 taxonomy_regulation_map
45 WHERE
46 taxonomy_regulation_map_id IN (:taxonomyregulationmapids)) list ON
47 list.taxonomy_regulation_map_id = trm.taxonomy_regulation_map_id