Commit 4d176ae7 authored by Oogie McGuire's avatar Oogie McGuire

New versions

Updated version based on latest year data
parent 28d10d6f
......@@ -20,7 +20,7 @@ INNER JOIN sheep_table AS dam_table ON sheep_table.dam_id = dam_table.sheep_id
INNER JOIN custom_evaluation_traits_table ON sheep_table.lambease = custom_evaluation_traits_table.id_custom_traitid
INNER JOIN sheep_evaluation_table ON sheep_table.sheep_id = sheep_evaluation_table.sheep_id
WHERE
sheep_evaluation_table.eval_date > "2017-06%"
sheep_evaluation_table.eval_date > "2018-08%"
AND
(sheep_evaluation_table.trait_name11 = 16 OR
sheep_evaluation_table.trait_name12 = 16 OR
......@@ -31,3 +31,4 @@ WHERE
(sheep_table.remove_date IS NULL OR sheep_table.remove_date is '')
ORDER BY
sheep_table.nsip_id asc
-- Get all the carcass weights for all sheep
-- Includes sort by sex
-- Includes sort by sex or by NSIP ID
SELECT
sheep_table.sheep_id
, sheep_table.nsip_id
, sheep_table.sheep_name
, sheep_sex_table.sex_abbrev
, sheep_table.birth_date
......@@ -18,7 +19,8 @@ WHERE
trait_name11 = 27
ORDER BY
years
, sheep_sex_table.sex_abbrev
, sheep_table.nsip_id
-- , sheep_sex_table.sex_abbrev
, sheep_table.birth_date ASC
-- This version gets carcass weights for sheep removed on a specific date or year
......@@ -39,9 +41,10 @@ FROM sheep_evaluation_table
INNER JOIN sheep_sex_table ON sheep_table.sex = sheep_sex_table.sex_sheepid
WHERE
trait_name11 = 27
AND sheep_table.remove_date LIKE "2017-06%"
AND sheep_table.remove_date LIKE "2018-09%"
ORDER BY
years
, sheep_sex_table.sex_abbrev
, sheep_table.birth_date ASC
-- Gets all drugs given on a specific date with the sheep name, drug ID number,
-- drug task and bpth date and time given.
-- drug task and both date and time given.
SELECT
sheep_drug_table.id_sheepdrugid
......@@ -13,8 +13,8 @@ FROM sheep_table
INNER JOIN sheep_drug_table ON sheep_table.sheep_id = sheep_drug_table.sheep_id
INNER JOIN drug_table ON sheep_drug_table. drug_id = drug_table.id_drugid
WHERE
sheep_drug_table.drug_date_on LIKE "2018-07-20%"
sheep_drug_table.drug_date_on LIKE "2018-12-03%"
-- Uncomment this to get a specific drug using the proper drug ID number
-- AND sheep_drug_table.drug_id = 56
-- AND sheep_drug_table.drug_id = 53
ORDER BY
sheep_drug_table.drug_time_on ASC
......@@ -18,12 +18,13 @@ SELECT
+ sheep_evaluation_table.trait_score08
+ sheep_evaluation_table.trait_score09
+ sheep_evaluation_table.trait_score10
+ (sheep_evaluation_table.trait_score12/10)
) AS overall_score
, sheep_evaluation_table.trait_score11
, sheep_evaluation_table.trait_score11 as weight
FROM sheep_evaluation_table
INNER JOIN sheep_table ON sheep_evaluation_table.sheep_id = sheep_table.sheep_id
WHERE
eval_date LIKE "2017-04-23"
eval_date LIKE "2018-11-09"
ORDER BY
nsip_id
, overall_score DESC
......
......@@ -32,7 +32,7 @@ LEFT JOIN sheep_table AS dam_table ON sheep_table.dam_id = dam_table.sheep_id
INNER JOIN custom_evaluation_traits_table ON sheep_table.lambease = custom_evaluation_traits_table.id_custom_traitid
WHERE
(sheep_table.lambease= 10 OR sheep_table.lambease= 11 OR sheep_table.lambease= 12 OR sheep_table.lambease= 13)
AND sheep_table.birth_date LIKE "2016%"
AND sheep_table.birth_date LIKE "2018%"
ORDER BY
dam_name
......
......@@ -25,8 +25,8 @@ INNER JOIN sheep_evaluation_table on sheep_table.sheep_id = sheep_evaluation_tab
LEFT JOIN sheep_sex_table ON sheep_table.sex = sheep_sex_table.sex_sheepid
WHERE
-- Set this to be the range that includes the evaluation dates for the lambs for this year
sheep_evaluation_table.eval_date > "2017-07%"
AND sheep_evaluation_table.eval_date < "2017-09%"
sheep_evaluation_table.eval_date > "2018-08%"
AND sheep_evaluation_table.eval_date < "2018-09%"
-- Get only the records that record a weight in the trait_name11
-- This will need to match whatever location you used for the weights
AND sheep_evaluation_table.trait_name11 = 16
......@@ -34,7 +34,7 @@ WHERE
-- Add this if you want only current alive sheep
AND (sheep_table.remove_date IS NULL OR sheep_table.remove_date IS '')
-- Or use this to sort to a specific year of birth
AND (sheep_table.birth_date > "2017%" AND sheep_table.birth_date < "2018%" )
AND (sheep_table.birth_date > "2018%" AND sheep_table.birth_date < "2019%" )
ORDER BY
-- Can add other sorting as desired. Watch out for having proper , in the query or it won't run
-- sheep_table.nsip_id
......@@ -45,3 +45,5 @@ ORDER BY
sheep_table.sheep_name
......@@ -27,11 +27,24 @@ SELECT
AND (tag_date_off IS NULL OR tag_date_off = '')
AND ( id_info_table.official_id IS NULL OR id_info_table.official_id = 0 ))
AS eidtag
-- Can add or delete items here by adding or removing -- in front of the item.
, sheep_table.sheep_name
, codon171_table.codon171_alleles
, sheep_ebv_table.usa_maternal_index
, sheep_ebv_table.self_replacing_carcass_index
, sheep_ebv_table.ebv_birth_weight
, sheep_ebv_table.ebv_wean_weight
-- , sheep_ebv_table.ebv_post_wean_weight
-- , sheep_ebv_table.ebv_hogget_weight
-- , sheep_ebv_table.ebv_adult_weight
-- , sheep_ebv_table.ebv_post_wean_scrotal
, sheep_ebv_table.ebv_number_lambs_born
, sheep_ebv_table.ebv_number_lambs_weaned
-- , sheep_ebv_table.ebv_maternal_birth_weight
-- , sheep_ebv_table.ebv_maternal_wean_weight
-- , sheep_ebv_table.ebv_lambease_direct
-- , sheep_ebv_table.ebv_lambease_daughter
, cluster_table.cluster_name
, sheep_table.birth_date
, sheep_sex_table.sex_abbrev
......@@ -39,7 +52,9 @@ SELECT
, sire_table.sheep_name as sire_name
, dam_table.sheep_name as dam_name
, sheep_table.alert01
FROM sheep_table
INNER JOIN codon171_table ON sheep_table.codon171 = codon171_table.id_codon171id
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
......@@ -48,10 +63,11 @@ LEFT JOIN sheep_table AS dam_table ON sheep_table.dam_id = dam_table.sheep_id
LEFT OUTER JOIN sheep_cluster_table ON sheep_table.sheep_id = sheep_cluster_table.sheep_id
LEFT JOIN cluster_table ON cluster_table.id_clusternameid = sheep_cluster_table.which_cluster
-- Edit the date to be the most recent run of EBV data by changing the date
-- Edit the date to be the most recent run of EBV data by changing the date below
LEFT OUTER JOIN sheep_ebv_table ON sheep_table.sheep_id = sheep_ebv_table.sheep_id
-- Modify this to be the latest EBV run date. Should be a way to get this automatically but I haven't figured it out.
AND sheep_ebv_table.ebv_date LIKE "2018-07%"
AND sheep_ebv_table.ebv_date LIKE "2018-09%"
WHERE
(sheep_table.remove_date IS NULL
OR sheep_table.remove_date IS '')
......@@ -59,15 +75,23 @@ WHERE
-- 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
-- AND sheep_table.sex = 1
-- To get no butcher or sell add this in the WHERE clause
-- AND (sheep_table.alert01 NOT LIKE "%Sell%"
-- AND sheep_table.alert01 NOT LIKE "%Butcher%")
-- To get only butcher or sell add this in the WHERE clause
-- AND (sheep_table.alert01 LIKE "%Sell%"
-- OR sheep_table.alert01 LIKE "%Butcher%")
-- To get only a specific alert add this in the WHERE clause
-- AND sheep_table.alert01 LIKE "%Sold%"
-- Change the text between the % to be what alert you are looking for.
-- Common ones include Sell, Butcher, Keep and so on.
-- AND sheep_table.alert01 LIKE "%Sell%"
-- To get only older sheep not current year lambs add this in the WHERE clause changing the year as required
-- To get only this years lambs change the < to a >
-- AND sheep_table.birth_date < "2018%"
-- AND sheep_table.birth_date < "2018%"
ORDER BY
sheep_sex_table.sex_abbrev ASC
......@@ -75,3 +99,4 @@ ORDER BY
, sheep_ebv_table.self_replacing_carcass_index DESC
, 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