This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT sum(total * 1), r.merchant | |
| FROM summaries s | |
| JOIN retailers r | |
| ON s.retailer_id = r.id | |
| JOIN ( | |
| SELECT sum(total) top_5_total, r.merchant AS top_5_merchant | |
| FROM summaries s | |
| JOIN retailers r | |
| ON s.retailer_id = r.id | |
| WHERE item_date >= '2007-01-01' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SET QUOTED_IDENTIFIER ON | |
| GO | |
| SET ANSI_NULLS ON | |
| GO | |
| /****** Object: Stored Procedure dbo.PR_T09 Script Date: 2/3/2006 4:17:47 PM ******/ | |
| ALTER PROCEDURE dbo.PR_T09 | |
| ( | |
| @YEAR1 char(4) = '2006' | |
| ,@QTR1 char(6) = 'Q1' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript"> | |
| var tabber1 = new Yetii({ | |
| id: 'tab-container-1', | |
| active: 4 | |
| }); | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| UPDATE revplan_infos | |
| AS ri SET | |
| ri.retail_margin = (SELECT (ri.amount * partner_infos.retail_margin/100) | |
| FROM partner_infos | |
| WHERE ri.partner_id = partner_infos.partner_id) | |
| WHERE revplan_id = 3 | |
| AND revplan_type = 'Plan' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT t_plan.partner_id, | |
| plan_amount – for_amount variance | |
| FROM | |
| (SELECT partner_id, amount plan_amount | |
| FROM revplan_infos | |
| WHERE revplan_type = 'Plan') t_plan | |
| JOIN ( | |
| SELECT partner_id, amount for_amount | |
| FROM revplan_infos | |
| WHERE revplan_type = 'Forecast') t_for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def forecast | |
| x = params[:revplan_id].to_i | |
| @revplan = Revplan.find(x) | |
| sql = ActiveRecord::Base.connection(); | |
| sql.execute "SET autocommit=0"; | |
| sql.begin_db_transaction | |
| execution_string="call sp_generate_forecast(#{Time.now.month}, #{Time.now.year}, _ | |
| #{x}, #{month_days(Time.now.month)})" | |
| result = sql.execute(execution_string) | |
| sql.commit_db_transaction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE PROCEDURE testy () | |
| BEGIN | |
| declare a, b int; | |
| DECLARE done int DEFAULT 0; | |
| DECLARE masterCursor CURSOR | |
| FOR | |
| SELECT SUM(sales.amount) amt, sales.item_month | |
| FROM sales |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT id | |
| FROM retailers | |
| WHERE id IN (SELECT retailer_id FROM sales) | |
| AND merchant = 'Ralphs' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT id | |
| FROM sales | |
| WHERE retailer_id IN | |
| (SELECT id | |
| FROM retailers | |
| WHERE merchant = 'Ralphs') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT r.id | |
| FROM retailers r | |
| RIGHT JOIN sales s | |
| ON s.retailer_id = r.id | |
| WHERE r.merchant = 'Ralphs' |