The document contains code snippets and SQL queries for various stored procedures and user defined functions related to reporting and data analysis, including functions to get the ISO year and week from a date, retrieve the first and last day of a month, and a stored procedure to generate a games overview report pulling data from various tables to summarize metrics like turnover, winnings, and active customers by game, date period, and customer market.
It also includes a query to retrieve customer data like account details, segmentation, and casino activity and revenue for a retention campaign analysis.
Speaker: André Spiegel
Many applications require processes that load large amounts of data into MongoDB. It is easy to get these processes wrong, resulting in hours or days of loading time when it could be done in minutes. This talk identifies common mistakes and pitfalls and shows design patterns that can dramatically improve performance. The patterns introduced here can be used with any tool or programming language.
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)Dan Robinson
At Heap, we lean on PostgreSQL for all our backend heavy lifting. We support an expressive set of queries — conversion funnels with filtering and grouping, retention analysis, and behavioral cohorting to name a few — across billions of users and tens of billions of events. Results need to come back in a matter of seconds and reflect up-to-the-minute data.
This talk will discuss these challenges, with a particular focus on:
- Using CitusDB for interactive analysis across 50 terabytes of data and counting.
- PostgreSQL and Kafka: two great tastes that taste great together.
- UDFs in C and PL/pgSQL, partial indexes for pre-aggregation, and other tricks up our sleeves.
Speaker: André Spiegel
Many applications require processes that load large amounts of data into MongoDB. It is easy to get these processes wrong, resulting in hours or days of loading time when it could be done in minutes. This talk identifies common mistakes and pitfalls and shows design patterns that can dramatically improve performance. The patterns introduced here can be used with any tool or programming language.
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)Dan Robinson
At Heap, we lean on PostgreSQL for all our backend heavy lifting. We support an expressive set of queries — conversion funnels with filtering and grouping, retention analysis, and behavioral cohorting to name a few — across billions of users and tens of billions of events. Results need to come back in a matter of seconds and reflect up-to-the-minute data.
This talk will discuss these challenges, with a particular focus on:
- Using CitusDB for interactive analysis across 50 terabytes of data and counting.
- PostgreSQL and Kafka: two great tastes that taste great together.
- UDFs in C and PL/pgSQL, partial indexes for pre-aggregation, and other tricks up our sleeves.
apidays Singapore 2023 - Resilience to adaptability through digitisation
April 12 & 13, 2023
Iterate Faster with Dynamic Flows
Yee Hui Poh, Solutions Engineer at Wise
------
Check out our conferences at https://www.apidays.global/
Do you want to sponsor or talk at one of our conferences?
https://apidays.typeform.com/to/ILJeAaV8
Learn more on APIscene, the global media made by the community for the community:
https://www.apiscene.io
Explore the API ecosystem with the API Landscape:
https://apilandscape.apiscene.io/
MongoDB World 2014 - BillRun, Billing on top of MongoDBOfer Cohen
Presentation from MongoDB world conference 2014. BillRun is open-source billing system. Presentation demonstrate the advantages of MongoDB as storage for billing system.
Uncovering SQL Server query problems with execution plans - Tony DavisRed Gate Software
Presentation by Tony Davis at SQL in The City 2016. An execution plan tells you exactly which tables and indexes SQL Server accessed, in what order, and what other operations it performed to return the data your query needed. But sometimes, the plan for even the simplest-looking query can reveal nasty surprises.
This session describes how SQL Server generates and reuses execution plans and the implications this has for you as the developer. After a quick-start guide to retrieving and reading plans, we'll focus on techniques that can help you track down high-cost queries quickly.
We'll cover tools such as ANTS Performance Profiler, as well as scripts that hunt down execution plans for queries that caused expensive scans, sort warnings, and other issues. Examining those plans, you'll uncover the root cause of the problem, often revealing issues such as inefficient indexing, data type mismatches, and misuse of functions.
Learn more about ANTS Performance Profiler: http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/
Find out about all Redgate Products: http://www.red-gate.com/products/
Connect with Tony Davis on LinkedIn: https://www.linkedin.com/in/tony-davis-208b241
A good data model is key to getting the best performance from Apache Cassandra. The Log Structured Storage Engine and it's distributed architecture mean we cannot rely on a paradigm such as Normal Form to evaluate a model. Instead we need to design data models that support the read path of the application. In this talk Aaron Morton will walk through the key principles and patterns of a good CQL3 data model using simple examples.
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...Altinity Ltd
JSON is the king of data formats and ClickHouse has a plethora of features to handle it. This webinar covers JSON features from A to Z starting with traditional ways to load and represent JSON data in ClickHouse. Next, we’ll jump into the JSON data type: how it works, how to query data from it, and what works and doesn’t work. JSON data type is one of the most awaited features in the 2022 ClickHouse roadmap, so you won’t want to miss out. Finally, we’ll talk about Jedi master techniques like adding bloom filter indexing on JSON data.
Beyond php - it's not (just) about the codeWim Godden
Most PHP developers focus on writing code. But creating Web applications is about much more than just wrting PHP. Take a step outside the PHP cocoon and into the big PHP ecosphere to find out how small code changes can make a world of difference on servers and network. This talk is an eye-opener for developers who spend over 80% of their time coding, debugging and testing.
apidays Singapore 2023 - Resilience to adaptability through digitisation
April 12 & 13, 2023
Iterate Faster with Dynamic Flows
Yee Hui Poh, Solutions Engineer at Wise
------
Check out our conferences at https://www.apidays.global/
Do you want to sponsor or talk at one of our conferences?
https://apidays.typeform.com/to/ILJeAaV8
Learn more on APIscene, the global media made by the community for the community:
https://www.apiscene.io
Explore the API ecosystem with the API Landscape:
https://apilandscape.apiscene.io/
MongoDB World 2014 - BillRun, Billing on top of MongoDBOfer Cohen
Presentation from MongoDB world conference 2014. BillRun is open-source billing system. Presentation demonstrate the advantages of MongoDB as storage for billing system.
Uncovering SQL Server query problems with execution plans - Tony DavisRed Gate Software
Presentation by Tony Davis at SQL in The City 2016. An execution plan tells you exactly which tables and indexes SQL Server accessed, in what order, and what other operations it performed to return the data your query needed. But sometimes, the plan for even the simplest-looking query can reveal nasty surprises.
This session describes how SQL Server generates and reuses execution plans and the implications this has for you as the developer. After a quick-start guide to retrieving and reading plans, we'll focus on techniques that can help you track down high-cost queries quickly.
We'll cover tools such as ANTS Performance Profiler, as well as scripts that hunt down execution plans for queries that caused expensive scans, sort warnings, and other issues. Examining those plans, you'll uncover the root cause of the problem, often revealing issues such as inefficient indexing, data type mismatches, and misuse of functions.
Learn more about ANTS Performance Profiler: http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/
Find out about all Redgate Products: http://www.red-gate.com/products/
Connect with Tony Davis on LinkedIn: https://www.linkedin.com/in/tony-davis-208b241
A good data model is key to getting the best performance from Apache Cassandra. The Log Structured Storage Engine and it's distributed architecture mean we cannot rely on a paradigm such as Normal Form to evaluate a model. Instead we need to design data models that support the read path of the application. In this talk Aaron Morton will walk through the key principles and patterns of a good CQL3 data model using simple examples.
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...Altinity Ltd
JSON is the king of data formats and ClickHouse has a plethora of features to handle it. This webinar covers JSON features from A to Z starting with traditional ways to load and represent JSON data in ClickHouse. Next, we’ll jump into the JSON data type: how it works, how to query data from it, and what works and doesn’t work. JSON data type is one of the most awaited features in the 2022 ClickHouse roadmap, so you won’t want to miss out. Finally, we’ll talk about Jedi master techniques like adding bloom filter indexing on JSON data.
Beyond php - it's not (just) about the codeWim Godden
Most PHP developers focus on writing code. But creating Web applications is about much more than just wrting PHP. Take a step outside the PHP cocoon and into the big PHP ecosphere to find out how small code changes can make a world of difference on servers and network. This talk is an eye-opener for developers who spend over 80% of their time coding, debugging and testing.
1. 2013-today QA/QC of spatial data AKN
2013-2013 BI Analyst 6PM
Name
2007-2013 LPIS Administrator MZSV
1999-2007 Database Developer KBR
Phone
Email Education
1990-1995
2014-
Skills
Personal Skills
! "
"
#$
%
&
#
'@saso70
Excellent knowledge in RDBMS concepts
Worked on end-user testing and on-line retrieval
Maximizing Value-Added Performance (MVP)
Forward Operation Base (FOB) badges
Tracking 10,000 Local Nationals (LNs) and Third Country Nationals(TCNs).
Professional Skills
Points, Check Points, Logging
Exceptionally good problem solving and trouble shooting skills
Developed a new military database and badge template for the area
' # " # ( ) *+, -. /*. *.0 ) 1,-02 3
Profile
' # " #
Date of Birth
/+ ( 1,-0
Address
4 !! 5
1*00 6 7 "
3
8*+, -. /*. *.0
1,-02 3
Social
Bachelor of Science Major in Geodesy Science
MCSA: SQL Server 2012
Prepared 7 themes for Euro Regional-Map including :Admin Border,
Hydrography, Transportation, Built-up areas, Soil and vegetation,
Miscellaneous object and named locations,Creating ERM Data Model
has gathered all feature classes into a georelational data model.
Creating drill down, drill through and linked reports using SSRS
Develop Business Intelligence reports, dashboards, and related visuals
Testing reports created in new QlikView
Utilizing SSIS 2012 creating package for Incremental and initial Load
Experience in Extraction, Transforming and Loading (ETL)
Experience in Error and Event Handling: Precedence Constraints, Break
MY SELF
2. Casino Campaigns – Retention
SELECT
tm.merchantName,
tb.brandName,
'Retention' AS ListType,
tc.customerEmail AS [E-Mail],
tc.customerFirstName AS [First Name],
CASE WHEN tc.countryCode IN ('SE', 'NO', 'FI', 'LV', 'PL','AT','CH','DE') THEN tcy.countryName
ELSE 'ROW'
END Country,
vus.segmentName AS [Main Segment],
vussub.segmentName AS [Sub Segment],
tc.customerCellPhone AS [Mobile Phone Number],
tc.customerRegistrationLanguageCode AS registrationLanguageCode,
cm.level1FriendlyName AS customerMarketName,
tc.src_customerId AS srcCustomerId,
ISNULL(ISNULL(temp.casinoModuleUserName,cpm.providerAlias),'NOT AVAILABLE') AS netEntCasinoUserId,
tc.AcceptSmsOffers AS [Accept SMS Offers],
tc.AcceptEmailOffers AS [Accept Newsletter],
tc.lastLoginGMT AS LastLoginDate,
DATEDIFF(DAY,tc.lastLoginGMT,GETDATE()) AS daysSinceLastLogin,
tc.lastPlayedNetentCasinoGMT AS lastActiveDate,
DATEDIFF(DAY,tc.lastPlayedNetentCasinoGMT,GETDATE()) AS daysSinceLastActive,
tc.firstDepositGMT AS firstDepositDate,
DATEDIFF(DAY,tc.firstDepositGMT,GETDATE()) AS daysSinceFirstDeposit,
tus.customerStatus AS accountStatus,
gamewinAllCasino.customerRevenue AS lifetimeCasinoAccountingRevenue ,
CASE WHEN DATEDIFF(month,tc.firstPlayedNetentCasinoGMT,tc.lastPlayedNetentCasinoGMT) = 0 THEN gamewinAllCasino.customerRevenue
ELSE (gamewinNetEnt.customerRevenue / DATEDIFF(month,tc.firstPlayedNetentCasinoGMT,tc.lastPlayedNetentCasinoGMT))
end AS averageCasinoAccountingRevenuePerActiveCasinoMonth,
DepositAmt.pmtDepositAmount AS lifetimeDepositAmount
FROM TDM..tcurrentCustomer tc (NOLOCK)
inner join TDM..tcustomerState tus (NOLOCK) on tus.sk_customerState = tc.sk_customerState
inner join TDM..tsegment vus (NOLOCK) on vus.segmentID = tc.currentSegmentID
inner join TDM..tsegment vussub (NOLOCK) on vussub.segmentID = tc.currentSubSegmentID
INNER JOIN tdw..tmerchant tm ON tm.sk_merchant = tc.sk_merchant
INNER JOIN tdw..tbrand tb ON tc.sk_registerBrand = tb.sk_brand
INNER JOIN tdw..tcustomerMarket cm ON cm.customerMarketID = tc.customerMarketID
LEFT JOIN tdw..tcountry tcy ON tc.countryCode = tcy.CountryCode
left join ( SELECT
gs.sk_customer,
gs.casinoModuleUserName
from TDW..tgameStatNetentCasinoDaily gs
inner join
(
SELECT
MAX(gs.calendarDateCET) lastcalendarDateCET,
gs.sk_customer
FROM TDW..tgameStatNetentCasinoDaily gs
GROUP BY
gs.sk_customer
) gs_un on gs.calendarDateCET = gs_un.lastcalendarDateCET and gs_un.sk_customer = gs.sk_customer
WHERE gs.migrationSourceID = -1
AD-HOC QUERY
3. Casino Campaigns – Retention
AD-HOC QUERY
) temp ON temp.sk_customer = tc.sk_customer
left join TDW..tcustomerProviderMapping cpm ON tc.sk_customer = cpm.sk_customer AND cpm.sk_provider = 1
left join
(
select pgs.sk_customer, SUM(pgs.revenue_EUR) as customerRevenue, sum(pgs.bet_EUR) as lifetimeBet
from tdm..tproviderGameStat pgs (NOLOCK)
INNER JOIN tdw..tprovider tp ON pgs.sk_provider = tp.sk_provider
WHERE tp.biProductID = 2
group by pgs.sk_customer
) gamewinAllCasino
on tc.sk_customer = gamewinAllCasino.sk_customer
left join
(
select pgs.sk_customer, SUM(pgs.revenue_EUR) as customerRevenue, sum(pgs.bet_EUR) as lifetimeBet
from tdm..tproviderGameStat pgs (NOLOCK)
WHERE pgs.sk_provider = 1
group by pgs.sk_customer
) gamewinNetEnt
on tc.sk_customer = gamewinNetEnt.sk_customer
left join
(
select ti.sk_customer, SUM(ti.pmtAmount_EUR) as pmtDepositAmount
from tdm..tpmtTransactionInfo ti (NOLOCK)
where ti.sk_pmtStatus in (2, 3)
and ti.sk_pmtType = 1
group by ti.sk_customer
) DepositAmt
on tc.sk_customer = DepositAmt.sk_customer
WHERE tc.lastLoginGMT >= (DATEADD(d,-45,GETDATE()))
AND (vus.segmentName IN ('NDC', 'SP', 'RP', 'IP', 'VIP1', 'VIP2', 'VIP3', 'VIP4', 'VIPN', 'NRC', 'VIP_POTENTIAL',)
AND vussub.segmentName IN ('CASINO_CRY', 'CASINO_EVO', 'CASINO_GTS', 'CASINO_MGC', 'CASINO_NTN', 'CASINO_PNG,
'SPORT_CASINO', 'CASINO_POKER', 'POKER_CASINO', 'MULTIPRODUCTS'))
AND tc.sk_registerBrand = 19
and tc.countryCode NOT IN ('BE','CA','CN','GR','MY','NL','PT','RO','UA')
4. Casino Campaigns – Retention
GET ISO WEEK
CREATE FUNCTION [DBO].[fnGetIsoYearIsWeek]
(
@THEDATE DATETIME
)
RETURNS NVARCHAR(10)
AS
BEGIN
DECLARE @MONTH INT, @WEEK INT
SET @WEEK = DATEPART(ISOWK, @THEDATE)
SET @MONTH = DATEPART(MONTH, @THEDATE)
IF @WEEK = 53 AND @MONTH = 1 BEGIN
RETURN CONVERT(NVARCHAR(4), DATEPART(YEAR, DATEADD(YEAR, -1, @THEDATE))) +
' W.' + RIGHT('0'+ CONVERT(VARCHAR,DATEPART(ISOWK, @THEDATE)),2)
END
IF @WEEK = 1 AND @MONTH = 12 BEGIN
RETURN CONVERT(NVARCHAR(4), DATEPART(YEAR, DATEADD(YEAR, 1, @THEDATE))) +
' W.' + RIGHT('0'+ CONVERT(VARCHAR,DATEPART(ISOWK, @THEDATE)),2)
END
RETURN CONVERT(NVARCHAR(4), DATEPART(YEAR, @THEDATE)) +
' W.' + RIGHT('0'+ CONVERT(VARCHAR,DATEPART(ISOWK, @THEDATE)),2)
END
GET FIRST DAY OF MONTH
CREATE FUNCTION [dbo].[ufn_GetFirstDayOfMonth] ( @pInputDate DATETIME )
RETURNS DATETIME
BEGIN
RETURN CAST(CAST(YEAR(@pInputDate) AS VARCHAR(4)) + '-' +
CAST(MONTH(@pInputDate) AS VARCHAR(2)) + '-01' AS DATETIME)
END
GET LAST DAY OF MONTSELECT
gs.sk_customer,
CREATE FUNCTION [dbo].[ugs.casinoModuleUserName
RETURNS DATETIME from TDW..tgameStatNetentCasinoDaily gs
BEGIN inner join
DECLARE (
SET @vOutputDate = SELECT
MAX(gs.calendarDateCET) lastcalendarDateCET,
SET @vOutputDate = gs.sk_customer
RETURN @vOutputDateFROM TDW..tgameStatNetentCasinoDaily gs
END
UDF-Functions
5. Casino Campaigns – Retention
USE [TDM]
GO
CREATE PROCEDURE [dbo].[rpt_overview_report_Games_overview]
@startDate datetime,
@endDate datetime,
@customerMarketID_List TEXT,
@groupBy int = 0,
@sk_customerType int = 1 -- User2 - Test User
with recompile AS
BEGIN
CREATE TABLE #customerMarket
(
customerMarketID INT
)
INSERT INTO #customerMarket
SELECT *
FROM ProcessRepository..fnSplitText(@customerMarketID_List) s
------
SELECT
ISNULL(gt.[gameType],'Not Classified') AS [gameType],
g.gameName ,
CASE WHEN @groupBy = 0
THEN CONVERT(NVARCHAR(10), DATEADD(DAY, DATEDIFF(DAY, 0,gs.calendarDateCET), 0), 120)
WHEN @groupBy = 1
THEN tdm.dbo.fnGetIsoYearIsoWeek(gs.calendarDateCET)
WHEN @groupBy = 2
THEN CONVERT(NVARCHAR(4), DATEPART(YEAR, gs.calendarDateCET)) + '-' +
RIGHT('0' + CONVERT(VARCHAR, DATEPART(MONTH, gs.calendarDateCET)),2)
WHEN @groupBy = 3
THEN CONVERT(NVARCHAR(30), DATEADD(DAY,DATEDIFF(DAY, 0, @startDate),0), 112)
+ ' - '+ CONVERT(NVARCHAR(30), DATEADD(DAY, DATEDIFF(DAY, 0, @endDate), 0), 112)
END AS period,
SUM(gs.bet) AS Turnover ,
SUM(gs.win) AS Winings ,
COUNT(gs.sk_customer) AS count_ActiveCustomers
FROM tgamestat gs
INNER JOIN dbo.tgame g ON gs.gameID = g.gameID
LEFT OUTER JOIN kufa88GameTypes gt ON gt.game = g.gameName
INNER JOIN tdm..tcurrentCustomer cc (NOLOCK) ON gs.sk_customer = cc.sk_customer
INNER JOIN #customerMarket cm ON cm.customerMarketID = cc.customerMarketID
WHERE gs.calendarDateCET >= @startDate
AND gs.calendarDateCET <= @endDate
AND gs.gameID <> -1
--AND cc.sk_customerType = @sk_customerType -- both Regular and Test Users will be included
GROUP BY gt.[gameType] ,
g.gameName ,
CASE WHEN @groupBy = 0
THEN CONVERT(NVARCHAR(10), DATEADD(DAY, DATEDIFF(DAY, 0,gs.calendarDateCET), 0), 120)
WHEN @groupBy = 1
THEN tdm.dbo.fnGetIsoYearIsoWeek(gs.calendarDateCET)
WHEN @groupBy = 2
SSRS-Report
6. Casino Campaigns – Retention
SSRS-Report
THEN CONVERIGHT('0' + CONVERT(VARCHAR, DATEPART(MONTH, gs.calendarDateCET)),2)
WHEN @groupBy = 3
THEN CONVECONVERT(NVARCHAR(30), DATEADD(DAY, DATEDIFF(DAY, 0, @endDate), 0), 112)
END
---------------------------------------
DROP TABLE #customerMarket
END