Skip to content

Instantly share code, notes, and snippets.

@fernandolopes
Created November 28, 2012 13:05
Show Gist options
  • Select an option

  • Save fernandolopes/4161149 to your computer and use it in GitHub Desktop.

Select an option

Save fernandolopes/4161149 to your computer and use it in GitHub Desktop.
get_receiving_logs_for_creation
select distinct `receiving_logs`.`id` AS `id`,`receiving_logs`.`lot` AS `lot`,`receiving_logs`.`quantity` AS `quantity`,`receiving_logs`.`date` AS `date`,`receiving_logs`.`status` AS `status`,`products`.`description` AS `product_description`,`products`.`best_buy_date` AS `best_buy_date`,`products`.`weight` AS `weight`,`products`.`aflatoxin` AS `aflatoxin`,`products`.`free_fatty_acid` AS `free_fatty_acid`,`products`.`moisture` AS `moisture`,`products`.`peanut_protein` AS `peanut_protein`,`products`.`decay` AS `decay`,`products`.`breakage` AS `breakage`,`products`.`foreign_material` AS `foreign_material`,`products`.`insects_damage` AS `insects_damage`,`products`.`kernels_with_skin` AS `kernels_with_skin`,`products`.`lower_grade` AS `lower_grade`,`products`.`roaster_test` AS `roaster_test`,`products`.`salmonella_negative` AS `salmonella_negative`,`products`.`mold` AS `mold`,`products`.`color` AS `color`,`products`.`flavor` AS `flavor`,`products`.`odor` AS `odor`,`products`.`texture` AS `texture`,`products`.`sizing_max` AS `sizing_max`,`products`.`sizing_min` AS `sizing_min`,`product_types`.`description` AS `product_type_description`,`measurement_units`.`description` AS `units_description`,`suppliers`.`name` AS `supplier_name`,`employees`.`name` AS `inspected_by`,(select `se`.`status` from `supplier_evaluations` `se` where (`se`.`supplier_id` = `suppliers`.`id`) order by `se`.`date` desc limit 0,1) AS `evaluations_status`,(((select `p`.`value` from `parameters` `p` where ((`p`.`parameter_group_id` = 2) and (`p`.`key` = (select `se`.`status` from `supplier_evaluations` `se` where (`se`.`supplier_id` = `suppliers`.`id`) order by `se`.`date` desc limit 0,1)))) * `receiving_logs`.`quantity`) / 100) AS `quantity_min` from (((((`receiving_logs` join `products` on((`receiving_logs`.`product_id` = `products`.`id`))) join `product_types` on((`product_types`.`id` = `products`.`product_type_id`))) join `measurement_units` on((`measurement_units`.`id` = `products`.`measurement_unit_id`))) join `suppliers` on((`receiving_logs`.`supplier_id` = `suppliers`.`id`))) join `employees` on((`receiving_logs`.`inspected_by_id` = `employees`.`id`))) where (`suppliers`.`id` and (`receiving_logs`.`date` = (select max(`rl`.`date`) from `receiving_logs` `rl` where (`rl`.`lot` = `receiving_logs`.`lot`))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment