Advertisement
fernandezekiel

Untitled

Jun 14th, 2013
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 4.10 KB | None | 0 0
  1. ELECT `Quotation`.`id` AS `t0_c0`,
  2. `Quotation`.`opportunity_id` AS `t0_c1`, `Quotation`.`quotation_number` AS
  3. `t0_c2`, `Quotation`.`contact_id` AS `t0_c3`, `Quotation`.`date` AS
  4. `t0_c4`, `Quotation`.`description` AS `t0_c5`, `Quotation`.`discount` AS
  5. `t0_c6`, `Quotation`.`tax` AS `t0_c7`, `Quotation`.`discount_type` AS
  6. `t0_c8`, `Quotation`.`owner_id` AS `t0_c9`, `Quotation`.`coordinator_id` AS
  7. `t0_c10`, `Quotation`.`status` AS `t0_c11`, `Quotation`.`create_date` AS
  8. `t0_c12`, `Quotation`.`update_date` AS `t0_c13`, `Quotation`.`deleted` AS
  9. `t0_c14`, ROUND(SUM(qd.selling_price * qd.quantity),2) as totalAmount,
  10. ROUND(SUM(qd.selling_price * qd.quantity)*(1-(Quotation.discount/100)),2)
  11. as totalDiscountedAmount, ROUND(SUM(qd.selling_price *
  12. qd.quantity)*(1-(Quotation.discount/100))*(1+(Quotation.tax/100)),2) as
  13. totalTaxedAmount, SUM(sls.amount) AS totalSalesCredited, `qd`.`id` AS
  14. `t1_c0`, `qd`.`quotation_header_id` AS `t1_c1`, `qd`.`order_column` AS
  15. `t1_c2`, `qd`.`quantity` AS `t1_c3`, `qd`.`selling_price` AS `t1_c4`,
  16. `qd`.`internal_price` AS `t1_c5`, `qd`.`description` AS `t1_c6`,
  17. `qd`.`discount` AS `t1_c7`, `qd`.`discount_type` AS `t1_c8`, `sls`.`id` AS
  18. `t2_c0`, `sls`.`sales_agent_id` AS `t2_c1`, `sls`.`amount` AS `t2_c2`,
  19. `sls`.`quoation_id` AS `t2_c3`, `sls`.`status` AS `t2_c4`, `sls`.`comment`
  20. AS `t2_c5`, `sls`.`commission` AS `t2_c6`, `sls`.`sales_manager_id` AS
  21. `t2_c7`, `sls`.`created_at` AS `t2_c8`, `cid`.`id` AS `t3_c0`,
  22. `cid`.`username` AS `t3_c1`, `cid`.`email` AS `t3_c3`, `cid`.`create_at` AS
  23. `t3_c9`, `cid`.`lastvisit_at` AS `t3_c6`, `cid`.`superuser` AS `t3_c7`,
  24. `cid`.`status` AS `t3_c8`, `cidp`.`user_id` AS `t4_c0`, `cidp`.`first_name`
  25. AS `t4_c1`, `cidp`.`last_name` AS `t4_c2`, `cidp`.`branch_id` AS `t4_c3`,
  26. `cidp`.`sales_agent` AS `t4_c4`, `cidp`.`coordinator` AS `t4_c5`,
  27. `cidp`.`manager` AS `t4_c6`, `cidp`.`worker` AS `t4_c7`, `opp`.`id` AS
  28. `t5_c0`, `opp`.`name` AS `t5_c1`, `opp`.`customer_id` AS `t5_c2`,
  29. `opp`.`owner_id` AS `t5_c3`, `opp`.`amount` AS `t5_c4`, `opp`.`close_date`
  30. AS `t5_c5`, `opp`.`probability` AS `t5_c6`, `opp`.`status` AS `t5_c7`,
  31. `opp`.`stage` AS `t5_c8`, `opp`.`source` AS `t5_c9`, `opp`.`create_date` AS
  32. `t5_c10`, `opp`.`turbo` AS `t5_c11`, `opp`.`edmel` AS `t5_c12`,
  33. `opp`.`fabrication` AS `t5_c13`, `opp`.`contact_id` AS `t5_c14`,
  34. `opp`.`update_date` AS `t5_c15`, `opp`.`deleted` AS `t5_c16`, `opcu`.`id`
  35. AS `t6_c0`, `opcu`.`name` AS `t6_c1`, `opcu`.`trunkline` AS `t6_c2`,
  36. `opcu`.`fax` AS `t6_c3`, `opcu`.`directline` AS `t6_c4`, `opcu`.`operator`
  37. AS `t6_c5`, `opcu`.`description` AS `t6_c6`, `opcu`.`industry` AS `t6_c7`,
  38. `opcu`.`number_of_employees` AS `t6_c8`, `opcu`.`annual_revenue` AS
  39. `t6_c9`, `opcu`.`rating` AS `t6_c10`, `opcu`.`email` AS `t6_c11`,
  40. `opcu`.`website` AS `t6_c12`, `opcu`.`facebook` AS `t6_c13`,
  41. `opcu`.`twitter` AS `t6_c14`, `opcu`.`billing_address_id` AS `t6_c15`,
  42. `opcu`.`shipping_address_id` AS `t6_c16`, `opcu`.`owner_id` AS `t6_c17`,
  43. `opcu`.`deleted` AS `t6_c18`, `opcu`.`create_date` AS `t6_c19`,
  44. `opcu`.`update_date` AS `t6_c20`, `ow`.`id` AS `t7_c0`, `ow`.`username` AS
  45. `t7_c1`, `ow`.`email` AS `t7_c3`, `ow`.`create_at` AS `t7_c9`,
  46. `ow`.`lastvisit_at` AS `t7_c6`, `ow`.`superuser` AS `t7_c7`, `ow`.`status`
  47. AS `t7_c8`, `owp`.`user_id` AS `t8_c0`, `owp`.`first_name` AS `t8_c1`,
  48. `owp`.`last_name` AS `t8_c2`, `owp`.`branch_id` AS `t8_c3`,
  49. `owp`.`sales_agent` AS `t8_c4`, `owp`.`coordinator` AS `t8_c5`,
  50. `owp`.`manager` AS `t8_c6`, `owp`.`worker` AS `t8_c7` FROM
  51. `quotation_header` `Quotation`  LEFT OUTER JOIN `quotation_detail` `qd` ON
  52. (`qd`.`quotation_header_id`=`Quotation`.`id`)  LEFT OUTER JOIN `sale` `sls`
  53. ON (`sls`.`quoation_id`=`Quotation`.`id`)  LEFT OUTER JOIN `users` `cid` ON
  54. (`Quotation`.`coordinator_id`=`cid`.`id`)  LEFT OUTER JOIN `profiles`
  55. `cidp` ON (`cidp`.`user_id`=`cid`.`id`)  LEFT OUTER JOIN `opportunity`
  56. `opp` ON (`Quotation`.`opportunity_id`=`opp`.`id`)  LEFT OUTER JOIN
  57. `customer` `opcu` ON (`opp`.`customer_id`=`opcu`.`id`)  LEFT OUTER JOIN
  58. `users` `ow` ON (`Quotation`.`owner_id`=`ow`.`id`)  LEFT OUTER JOIN
  59. `profiles` `owp` ON (`owp`.`user_id`=`ow`.`id`)  GROUP BY
  60. qd.quotation_header_id, sls.quoation_id LIMIT 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement