Commit dab10aa8 authored by Oogie McGuire's avatar Oogie McGuire

newDB queries

Got the overall list working properly now. Scrapie counts still failing.
parent 79105d31
-- Gets whole list of current sheep properly including sheep without a sire or dam or without EBVs
-- This version only gets sheep located at Contact number 1 which is is at Garvin Mesa
SELECT
sheep_table.sheep_id
......@@ -52,6 +53,15 @@ SELECT
, sire_table.sheep_name as sire_name
, dam_table.sheep_name as dam_name
, sheep_table.alert01
-- This is what gets only the sheep that are still alive and located here at location 1
, (SELECT
to_id_contactsid
FROM sheep_location_history_table
WHERE
to_id_contactsid = "1"
AND sheep_location_history_table.sheep_id = sheep_table.sheep_id
ORDER by movement_date DESC)
AS location
FROM sheep_table
......@@ -71,7 +81,8 @@ LEFT OUTER JOIN sheep_ebv_table ON sheep_table.sheep_id = sheep_ebv_table.sheep_
-- Need to fix this to deal with the new ownership tables an no more remove_date
-- This still gets all sheep that have been sold for breeding too
WHERE
sheep_table.death_date = ""
sheep_table.death_date = ""
and location = "1"
-- To get only a single sex add this in the WHERE clause
-- Edit for sex by making Ram sex = 1 Ewe Sex = 2 Wether sex = 3
......@@ -99,4 +110,3 @@ ORDER BY
, cluster_table.cluster_name
, sheep_ebv_table.self_replacing_carcass_index DESC
, sheep_table.birth_date ASC
......@@ -42,13 +42,13 @@ SELECT
, sheep_table.birth_date
, sheep_sex_table.sex_abbrev
, birth_type_table.birth_type
, location_table.location_name
, farm_location_table.farm_location_name
FROM sheep_table
INNER JOIN codon171_table ON sheep_table.codon171 = codon171_table.id_codon171id
INNER JOIN flock_prefix_table ON sheep_table.flock_prefix = flock_prefix_table.flock_prefixid
LEFT JOIN birth_type_table ON sheep_table.birth_type = birth_type_table.id_birthtypeid
LEFT JOIN sheep_sex_table ON sheep_table.sex = sheep_sex_table.sex_sheepid
LEFT JOIN location_table ON sheep_table.id_locationid = location_table.id_locationid
LEFT JOIN farm_location_table ON sheep_table.id_locationid = farm_location_table.id_farmlocationid
WHERE
(sheep_table.remove_date IS NULL or sheep_table.remove_date is '')
-- Edit this to be the appropriate year to get either older or younger sheep.
......@@ -62,3 +62,5 @@ SELECT
, sheep_table.birth_date asc
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment