SlideShare a Scribd company logo
1 of 9
Download to read offline
KPI looking at Billable hours as a trend, a single team and analysis on types of time off. This provides statistics that were used by executives and
board members.
Dashboard Examples:
VSO – Visual Studios Online
Using Power BI and importing data from Zen Desk to discover Support Ticket Trends.
Obtain Next AvailableWO
WO has a
Number?
WO will not be sent
Create WO with
Provided
Template
Select Project
Management
Group
Create WO Entry in Site
Select Work
Orders Board
Client Exists?
HaveWO Admin
Add Client
Add Name of
WO
Fill Out WO#,
WO Date, Quote
& Deposit
Upload WO
Add Task to
Correct
Client
Send out WO via Email to Client
Create pdf of
WO
Send WO to
Client for
Approval
Signatures
Retrieve Necessary Client
Signature Page
Signed WO?
NO YES
No Work Order
Retrieve Signed
Signature Page
CHSI Officer
Sign the
Signature Page
Scan and Send
Fully Signed WO
to Client
Upload pdf to
Site and
Connections
UpdateDate
Accepted field
Verbally
Declined
WO not
Accepted in
Allotted # of
Days
Note Reason in
Site
Archive the Task
NO
WO Invoice
Amount?
Retrieve Invoice
# in Site
50% Deposit
Required
Notify
Accounting of
Amt
No deposit
Signed WO can
beScheduled
Retrieve
and Upload
Document
WO Greater
than $5000
WO Less
than $5000
Accounting fill
in Required
Fields
Deposit
Received
Signed WO can
beScheduled
Work Order
Updated
UpdateWO Status & Fields in Site
UpdateFields
WO Admin
Performs Data
Dump
Notify Accounting to Perform
Final Billing
Email Signed
WO to
Accounting w/
Amt Billed
Accounting
Updates
Information
Final Invoice #
Sent
Final Amt Rcvd
NO
YES
YES
WORK ORDER PROCESS
This report was created to show the Written Premium by Policy Number grouped by Agency.
The T-SQL below showcases how to I used declared variables and functions like case statements,
subqueries, row_number(),first_value() and last_value()
DECLARE @AsOfDate Date,
@GroupName varchar(20)
SET @AsOfDate = '6/30/2015'
SET @GroupName = 'FBIM'
SELECT clients.clientid,
clients.clientname,
clients.GroupID,
clients.ClientType,
[ContactInfo].contactname,
CASE WHEN [ProducerClients].producername is null
THEN 'No Producer Name Available'
ELSE [ProducerClients].producername
END [producername],
[ProducerClients].Address1,
[ProducerClients].Address2,
[ProducerClients].city,
[ProducerClients].State,
[ProducerClients].zip,
CASE WHEN ([ProducerClients].Address2 = '' OR [ProducerClients].Address2 IS NULL)
THEN [ProducerClients].Address1 + CHAR(13) + CHAR(10)
+ [ProducerClients].city
+ ', ' + [ProducerClients].State
+ ' ' + [ProducerClients].zip
ELSE [ProducerClients].Address1 + CHAR(13) + CHAR(10)
+ [ProducerClients].Address2 + CHAR(13) + CHAR(10)
+ [ProducerClients].city
+ ', ' + [ProducerClients].State
+ ' ' + [ProducerClients].zip
END ProducerAddress,
[ProducerClients].phone AS Phone,
CASE WHEN [ProducerClients].taxpayerid is null
THEN 'No id'
WHEN [ProducerClients].taxpayerid = ''
THEN 'No id'
ELSE [ProducerClients].taxpayerid
END taxpayerid,
ROUND([Calculations].[Writtenpremium],2) WrittenPremium,
[UWQuotes].policynumber,
Uwquotes.policyperiod [UWPoliyPeriod],
[ProducerClients].policyperiod [ProducerClientsPolicyPeriod],
CAST([UWQuotes].effectivedate AS DATE) EffectiveDate,
CAST(MONTH([UWQuotes].effectivedate) AS VARCHAR(2)) + '/' +
CAST(DAY([UWQuotes].effectivedate) AS VARCHAR(2))+ '/' +
CAST(YEAR([UWQuotes].effectivedate) AS VARCHAR(4)) [FormatEffectDate],
CAST([UWQuotes].expirationdate AS DATE) ExpirationDate,
DATENAME(dw,CAST(GetDate() AS DATETIME)) + ', ' +
DATENAME(month,CAST(GETDATE() AS datetime)) + ' ' +
DATENAME(day,CAST(GETDATE() AS datetime)) + ', ' +
DATENAME(year, CAST(GETDATE() AS datetime)) PrintDate
,uwquotes.QuoteRow
,uwquotes.createtmsp
,uwquotes.quotetype
,uwquotes.quoteid
FROM clients
LEFT JOIN (SELECT contacts.contactid,
contactname,
clientcontacts.clientid,
row_number() OVER (PARTITION BY clientcontacts.clientid
ORDER BY CASE WHEN PrimaryContact = 'Y'
THEN getdate()
ELSE contacts.updatetmsp
END DESC) rownumber
FROM contacts
INNER JOIN ClientContacts ON contacts.contactid = clientcontacts.contactid
WHERE contacts.STATUS = 'active'
AND clientcontacts.STATUS = 'active') [ContactInfo] ON
contactinfo.clientid = clients.clientid
AND contactinfo.rownumber = 1
CROSS APPLY (SELECT ISNULL(parentquote.policynumber, uwquotes.policynumber) [PolicyNumber]
, uwquotes.effectivedate
, uwquotes.expirationdate
, uwquotes.quoteid
, uwquotes.clientid
, uwquotes.policyperiod
, uwquotes.quotetype
, uwquotes.status
,uwquotes.createtmsp
, ROW_NUMBER() OVER (PARTITION BY uwquotes.policyperiod, uwquotes.clientid
ORDER BY uwquotes.quotetype DESC,
uwquotes.quotedate DESC,
uwquotes.createtmsp DESC,
(CASE WHEN uwquotes.parentquoteid IS NULL
THEN uwquotes.quoteid
ELSE uwquotes.parentquoteid
END) DESC,
uwquotes.policyperiod DESC) [QuoteRow]
,uwquotes.parentquoteid
FROM uwquotes
LEFT JOIN uwquotes [parentQuote] on uwquotes.parentquoteid = parentQuote.quoteid
WHERE uwquotes.clientid = clients.clientid
AND (@AsOfDate >= CAST([UWQuotes].effectivedate as date)
AND ((@AsOfDate < [UWQuotes].expirationdate)
OR [UWQuotes].expirationdate IS NULL))
AND uwquotes.STATUS = 'FINAL'
AND uwquotes.quotetype IN ('CHSI1','Endrse','WCAudit')
AND EXISTS (SELECT *
FROM uwquotepremiumcalc
WHERE quoteid = uwquotes.quoteid)
AND ((CASE WHEN uwquotes.parentquoteid IS NULL
THEN uwquotes.quoteid
ELSE uwquotes.ParentQuoteID
END) NOT IN (SELECT quoteid
FROM [ClientCancellation]
WHERE status = 'Cancelled'))) [uwquotes]
LEFT JOIN (SELECT ClientCommissionsProducers.ProducerID,
ClientCommissionsProducers.policyperiod,
dbo.ClientHierarchy.clientid,
dbo.ClientHierarchy.clientnumber,
dbo.ClientHierarchy.relatedclientnumber,
dbo.ClientHierarchy.topmostclientnumber,
dbo.ClientHierarchy.Depth,
isnull(childfilter.specvalue, 0) [ChildFilter],
ClientCommissionsProducers.quoteid
producers.producername,
producers.Address1,
producers.Address2,
producers.city,
producers.State,
producers.zip,
producers.phone,
producers.taxpayerid
FROM dbo.ClientHierarchy
INNER JOIN (SELECT producerID,
ClientID,
effectiveDate,
ExpirationDate,
policyperiod,
ROW_NUMBER() OVER (PARTITION BY producerid, clientid, policyperiod
ORDER BY quoteid DESC,
effectivedate DESC,
policyperiod DESC) [Row],
clientcommissions.quoteid
FROM clientcommissions
WHERE status <> 'deleted') [ClientCommissionsProducers] ON Row = 1
AND ClientCommissionsProducers.clientid =
ClientHierarchy.clientid
INNER JOIN clients ON clients.ClientID = ClientCommissionsProducers.clientid
LEFT OUTER JOIN dbo.GroupSpecs AS ChildFilter
ON ChildFilter.GroupName = clients.groupid
AND ChildFilter.SpecName = 'ChildUserFilterByComissions'
LEFT OUTER JOIN dbo.GroupSpecs AS DenyExpiredAccess
ON DenyExpiredAccess.GroupName = clients.groupid
AND DenyExpiredAccess.SpecName ='DenyBrkerAcctoExpCom'
INNER JOIN Producers
ON Producers.ProducerID = [ClientCommissionsProducers].ProducerID
WHERE (GETDATE() <= ClientCommissionsProducers.expirationdate
OR ISNULL(denyexpiredaccess.specvalue,0) = 1)
) [ProducerClients] ON (ProducerClients.ClientID = clients.clientid)
AND (CASE WHEN uwquotes.parentquoteid IS NULL
THEN uwquotes.quoteid
ELSE uwquotes.parentquoteid
END)=[ProducerClients].quoteid
INNER JOIN (SELECT quoteid,
SUM (CASE WHEN modid = firstmod
THEN resultamount
ELSE 0
END) [Manualpremium],
SUM (CASE WHEN modid = lastmod
THEN resultamount
ELSE 0
END) [Writtenpremium]
FROM (SELECT uwquotepremiumcalc.resultamount,
uwquotepremiumcalc.quoteid, assessmentmods.modid,
FIRST_VALUE( uwquotepremiumcalc.modid) OVER
(PARTITION BY uwquotepremiumcalc.quoteid
ORDER BY assessmentmods.sortorder
ROWS BETWEEN UNBOUNDED PRECEDING
AND UNBOUNDED FOLLOWING) [firstmod],
LAST_VALUE(uwquotepremiumcalc.modid) OVER
(PARTITION BY uwquotepremiumcalc.quoteid
ORDER BY assessmentmods.sortorder
ROWS BETWEEN UNBOUNDED PRECEDING
AND UNBOUNDED FOLLOWING) [lastmod]
FROM assessmentmods
INNER JOIN uwquotepremiumcalc
ON assessmentmods.modid = uwquotepremiumcalc.modid
WHERE resultamount <> 0 ) [QuoteModValues]
GROUP BY quoteid) [Calculations] ON Calculations.quoteid = uwquotes.quoteid
WHERE clients.groupid = @GroupName
AND (@AsOfDate >= CAST([UWQuotes].effectivedate as date)
AND ((@AsOfDate < [UWQuotes].expirationdate)
OR [UWQuotes].expirationdate IS NULL))
AND ([ProducerClients].policyperiod = Uwquotes.policyperiod
OR [ProducerClients].policyperiod IS NULL)
AND [UWQuotes].effectivedate <> [UWQuotes].expirationdate
AND uwquotes.QuoteRow = 1
ORDER BY Clients.clientname
This report is showing the contributions, itemized in each type of liability that this customer provides.
The report will only show one quote id.
This was done using the SQL function: Pivots
declare @QuoteID int
set @QuoteID = 1
Select * from
(select dbo.clientswithParentOrg.ClientName,
dbo.clientswithParentOrg.clientid,
dbo.clientswithParentOrg.billingaddress1,
dbo.clientswithParentOrg.billingaddress2,
dbo.clientswithParentOrg.billingcity,
dbo.clientswithParentOrg.billingstate,
dbo.clientswithParentOrg.billingzip,
UWQuotes.QuoteID,
UWQuotes.PolicyPeriod,
Datename(Month,UWQuotes.EffectiveDate) + Right(Convert(varchar(12),UWQuotes.EffectiveDate,107),9) EffectiveDate,
Datename(Month,UWQuotes.ExpirationDate) + Right(Convert(varchar(12),UWQuotes.ExpirationDate,107),9) ExpirationDate,
UWQuotes.PolicyNumber,
UWQuoteTypes.QTName,
program.programname,
coverageline.CoverageLine,
ProgramRate.ratename,
programratedetail.VariableName RateDetailVariableName,
programratevariable.VariableName ProgramRateVariableName,
choose(programratevariable.DataType,
quoteratevariable.stringvalue,
convert(varchar, quoteratevariable.datevalue, 101),
convert(varchar, quoteratevariable.decimalvalue),
convert(varchar,quoteratevariable.boolvalue),
convert(varchar, quoteratevariable.integervalue)) QuoteVariableValue
from (dbo.UWQuotes UWQuotes
inner join (dbo.UWQuoteTypes UWQuoteTypes
inner join uw.program program on program.programname = UWQuoteTypes.qtname) on UWQuoteTypes.qtname = UWQuotes.quotetype
inner join (uw.QuoteCoverageLine QuoteCoverageLine
inner join uw.coverageline coverageline on QuoteCoverageLine.CoverageLineID = coverageline.coveragelineid
inner join uw.ProgramRate ProgramRate on ProgramRate.Coveragelineid = coverageline.coveragelineid) on UWQuotes.QuoteID = QuoteCoverageLine.QuoteID
inner join ([UW].[QuoteRateInfo] [QuoteRateInfo]
inner join uw.programratedetail programratedetail on programratedetail.RateDetailID = [QuoteRateInfo].RateDetailID
inner join ((select *,
max(historyindex) over (partition by programratevariableid, rateinfoid) MaxHistoryIndex
from uw.quoteratevariable) quoteratevariable
inner join uw.programratevariable programratevariable on programratevariable.programratevariableid = quoteratevariable.programratevariableid
and quoteratevariable.HistoryIndex = quoteratevariable.MaxHistoryIndex
) on quoteratevariable.rateinfoid = [QuoteRateInfo].rateinfoid
) on [QuoteRateInfo].quoteid = UWQuotes.quoteid and [QuoteRateInfo].coveragelineid = QuoteCoverageLine.coveragelineid)
inner join dbo.clientswithParentOrg on clientswithParentOrg.clientid = UWQuotes.clientid
where UWQuotes.QuoteID = @QuoteID
) Source
Pivot(Max(QuoteVariableValue)
for ProgramRateVariableName in
(LELPOLPremium,Premium,Rate,EffectiveRate,HazardCount,Limit) ) as pvt
This report looks at the past 30 days of all policies and states the several calculated fields using SQL and Crystal
Report formatting.
The SQL utilitized the following functions: A Declared Table, IsNull, an Inner Join with a Pivot inside and
subqueries.
This report will render over 20 pages in SAP Crystal in under 5 seconds.
This SQL Query showcases my usage of table variables and the Pivot Function.
DECLARE @GroupName VARCHAR(20) = 'FBIM'
DECLARE @Payments TABLE (CountofPayments INT,
Payments INT,
PaidToDate INT,
ClientID INT,
PolicyPeriod INT,
AvgPayments INT,
AnnualizedPmts INT)
INSERT INTO @Payments
SELECT *,
[AvgPayments]*12 [AnnualizedPmts]
FROM (SELECT *,
CASE WHEN BulkData.[CountofPayments] = 0
THEN 0
ELSE CAST(ROUND((BulkData.[PaidToDate]/BulkData.[CountofPayments]),0) AS INT)
END [AvgPayments]
FROM (SELECT SUM(CASE WHEN creditamount = 0
THEN 0
ELSE 1
END) [CountofPayments],
COUNT(creditamount) [payments],
SUM(creditamount) [PaidToDate],
clientid,
PolicyPeriod
FROM [dbo].[AcctsRecvLog]
WHERE AccountNo in ('FB001','FB004')
AND YEAR(GETDATE()) = policyperiod
AND YEAR(GETDATE()) = YEAR(DateReceived)
AND GETDATE() >= DateReceived
GROUP BY Clientid,
PolicyPeriod
) BULKDATA
) [AvgPayments]
SELECT *,
CASE WHEN [WrittenPremium] is NULL
THEN 0-AnnualizedPmts
ELSE [WrittenPremium]-AnnualizedPmts
END [Difference]
FROM (SELECT clients.clientid,
clients.clientname,
clients.GroupID,
CAST(ROUND([PivotUWQuoteDetail].AnnualPremium,0) as INT) [EstAnnual],
CAST(ROUND([PivotUWQuoteDetail].WrittenPremium,0) as INT) [WrittenPremium],
[UWQuotes].policynumber,
[Uwquotes].quoteid,
CAST([UWQuotes].effectivedate as DATE) EffectiveDate,
CAST(MONTH([UWQuotes].effectivedate) as VARCHAR(2)) + '/' +
CAST(DAY([UWQuotes].effectivedate) as VARCHAR(2)) + '/' +
CAST(YEAR([UWQuotes].effectivedate) as VARCHAR(4))[FormatEffectDate],
CAST([UWQuotes].expirationdate as DATE) ExpirationDate,
CAST(MONTH([UWQuotes].expirationdate) as VARCHAR(2)) + '/' +
CAST(DAY([UWQuotes].expirationdate) as VARCHAR(2)) + '/' +
CAST(YEAR([UWQuotes].expirationdate) as VARCHAR(4))[FormatExpireDate],
CASE WHEN [payments].[CountofPayments] is NULL
THEN 0
ELSE [payments].[CountofPayments]
END [CountofPayments],
CASE WHEN [payments].[PaidToDate] is NULL
THEN 0
ELSE [payments].[PaidToDate]
END [PaidToDate],
[payments].AvgPayments,
[payments].AnnualizedPmts,
ISNULL(ClientGroups.LongName, Clients.GroupID) [LongName]
FROM clients
INNER JOIN (SELECT Longname,
GroupName
FROM [dbo].[ClientGroups]
WHERE ClientGroups.Status = 'Active') [ClientGroups]
ON Clients.Groupid = [ClientGroups].GroupName
INNER JOIN (SELECT DISTINCT dbo.ClientHierarchy.clientid,
dbo.ClientHierarchy.clientnumber,
dbo.ClientHierarchy.relatedclientnumber,
dbo.ClientHierarchy.topmostclientnumber,
dbo.ClientHierarchy.Depth,
isnull(childfilter.specvalue, 0) [ChildFilter]
FROM dbo.ClientHierarchy
INNER JOIN (SELECT ClientID,
effectiveDate,
ExpirationDate,
ROW_NUMBER() OVER (PARTITION BY producerid, clientid
ORDER BY effectivedate DESC) [Row]
FROM clientcommissions
WHERE status <> 'deleted') [ClientCommissionsProducers]
ON Row = 1 and ClientCommissionsProducers.clientid =
ClientHierarchy.clientid
INNER JOIN clients on clients.ClientID = ClientCommissionsProducers.clientid
LEFT OUTER JOIN dbo.GroupSpecs AS ChildFilter
ON ChildFilter.GroupName = clients.groupid
AND ChildFilter.SpecName = 'ChildUserFilterByComissions'
LEFT OUTER JOIN dbo.GroupSpecs AS DenyExpiredAccess
ON DenyExpiredAccess.GroupName = clients.groupid
AND DenyExpiredAccess.SpecName =
'DenyBrokerAccesstoExpiredCommissions'
WHERE GETDATE() <= ClientCommissionsProducers.expirationdate
OR ISNULL(denyexpiredaccess.specvalue,0) = 1) [ProducerClients]
ON (ProducerClients.ClientID = clients.clientid)
INNER JOIN (SELECT uwquotes.policynumber,
uwquotes.effectivedate,
uwquotes.expirationdate,
uwquotes.quoteid,
uwquotes.clientid,
uwquotes.policyperiod ,
uwquotes.quotetype
FROM uwquotes
WHERE status = 'FINAL'
AND quotetype = 'CHSI1') [UWQuotes]
ON UWQuotes.clientid = Clients.clientid
INNER JOIN (SELECT DISTINCT QuoteID,
[85] as AnnualPremium,
[86] as WrittenPremium
FROM (SELECT QuoteID,
FieldID,
FieldValue
FROM dbo.uwquotedetail
WHERE FieldID in (86,85) ) AS Src
PIVOT
(MAX(Fieldvalue) FOR FieldID IN ([86],[85]) ) AS QDPivot) [PivotUWQuoteDetail]
ON uwquotes.QuoteID = [PivotUWQuoteDetail].QuoteID
INNER JOIN @Payments [Payments] ON [Payments].Clientid = Clients.clientid
LEFT JOIN (SELECT ClientID,
QuoteId,
Status,
CancellationDate
FROM ClientCancellation
WHERE cancellationDate <= CAST(GETDATE() as DATE)
AND cancellationdate >= CAST(DATEADD(day, -30, GETDATE()) as date)
AND [ReinstatementDate] is NULL
AND [RescissionDate] is NULL) [ClientCancellation]
ON [ClientCancellation].clientid = Clients.clientid
AND [ClientCancellation].quoteid = [UWQuotes].quoteid
) BulkData
WHERE BulkData.groupid = @GroupName AND CAST(GETDATE() as date) >= EffectiveDate
AND CAST(GETDATE() as date) <= ExpirationDate
ORDER BY [Difference]

More Related Content

Similar to Portfolio

Add Client in OfficeTimer - Fully Free Time Tracking, HR and Project Manageme...
Add Client in OfficeTimer - Fully Free Time Tracking, HR and Project Manageme...Add Client in OfficeTimer - Fully Free Time Tracking, HR and Project Manageme...
Add Client in OfficeTimer - Fully Free Time Tracking, HR and Project Manageme...OfficeTimer
 
Building and deploying microservices with event sourcing, CQRS and Docker (Be...
Building and deploying microservices with event sourcing, CQRS and Docker (Be...Building and deploying microservices with event sourcing, CQRS and Docker (Be...
Building and deploying microservices with event sourcing, CQRS and Docker (Be...Chris Richardson
 
Document process v7
Document process v7Document process v7
Document process v7Bala Kris
 
Programming the ExactTarget Marketing Cloud
Programming the ExactTarget Marketing CloudProgramming the ExactTarget Marketing Cloud
Programming the ExactTarget Marketing CloudSalesforce Developers
 
QCon 2019 - Opportunities and Pitfalls of Event-Driven Utopia
QCon 2019 - Opportunities and Pitfalls of Event-Driven UtopiaQCon 2019 - Opportunities and Pitfalls of Event-Driven Utopia
QCon 2019 - Opportunities and Pitfalls of Event-Driven UtopiaBernd Ruecker
 
ELEVATE Advanced Workshop
ELEVATE Advanced WorkshopELEVATE Advanced Workshop
ELEVATE Advanced WorkshopJoshua Birk
 
Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...
Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...
Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...Codemotion
 
Detroit ELEVATE Track 2
Detroit ELEVATE Track 2Detroit ELEVATE Track 2
Detroit ELEVATE Track 2Joshua Birk
 
SVCC Developing Asynchronous, Message-Driven Microservices
SVCC Developing Asynchronous, Message-Driven Microservices  SVCC Developing Asynchronous, Message-Driven Microservices
SVCC Developing Asynchronous, Message-Driven Microservices Chris Richardson
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...Chris Richardson
 
Budget Proposal Template PowerPoint Presentation Slides
Budget Proposal Template PowerPoint Presentation SlidesBudget Proposal Template PowerPoint Presentation Slides
Budget Proposal Template PowerPoint Presentation SlidesSlideTeam
 
Data.com APIs in Action ? Bringing Data to Life in Salesforce
Data.com APIs in Action ? Bringing Data to Life in SalesforceData.com APIs in Action ? Bringing Data to Life in Salesforce
Data.com APIs in Action ? Bringing Data to Life in SalesforceSalesforce Developers
 
Agados-based Application Design Demo
Agados-based Application Design Demo Agados-based Application Design Demo
Agados-based Application Design Demo Yongkyoo Park
 
Building Competing Models Using Apache Spark DataFrames with Abdulla Al-Qawasmeh
Building Competing Models Using Apache Spark DataFrames with Abdulla Al-QawasmehBuilding Competing Models Using Apache Spark DataFrames with Abdulla Al-Qawasmeh
Building Competing Models Using Apache Spark DataFrames with Abdulla Al-QawasmehDatabricks
 

Similar to Portfolio (20)

Add Client in OfficeTimer - Fully Free Time Tracking, HR and Project Manageme...
Add Client in OfficeTimer - Fully Free Time Tracking, HR and Project Manageme...Add Client in OfficeTimer - Fully Free Time Tracking, HR and Project Manageme...
Add Client in OfficeTimer - Fully Free Time Tracking, HR and Project Manageme...
 
Building and deploying microservices with event sourcing, CQRS and Docker (Be...
Building and deploying microservices with event sourcing, CQRS and Docker (Be...Building and deploying microservices with event sourcing, CQRS and Docker (Be...
Building and deploying microservices with event sourcing, CQRS and Docker (Be...
 
Document process v7
Document process v7Document process v7
Document process v7
 
CASE STUDY 3- NEW PROJECT
CASE STUDY 3- NEW PROJECTCASE STUDY 3- NEW PROJECT
CASE STUDY 3- NEW PROJECT
 
FINAL-Review
FINAL-ReviewFINAL-Review
FINAL-Review
 
Banking Database
Banking DatabaseBanking Database
Banking Database
 
Programming the ExactTarget Marketing Cloud
Programming the ExactTarget Marketing CloudProgramming the ExactTarget Marketing Cloud
Programming the ExactTarget Marketing Cloud
 
QCon 2019 - Opportunities and Pitfalls of Event-Driven Utopia
QCon 2019 - Opportunities and Pitfalls of Event-Driven UtopiaQCon 2019 - Opportunities and Pitfalls of Event-Driven Utopia
QCon 2019 - Opportunities and Pitfalls of Event-Driven Utopia
 
ELEVATE Advanced Workshop
ELEVATE Advanced WorkshopELEVATE Advanced Workshop
ELEVATE Advanced Workshop
 
Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...
Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...
Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...
 
Apex Design Patterns
Apex Design PatternsApex Design Patterns
Apex Design Patterns
 
6 Sigma
6 Sigma6 Sigma
6 Sigma
 
Detroit ELEVATE Track 2
Detroit ELEVATE Track 2Detroit ELEVATE Track 2
Detroit ELEVATE Track 2
 
Introduction to Data.com APIs
Introduction to Data.com APIsIntroduction to Data.com APIs
Introduction to Data.com APIs
 
SVCC Developing Asynchronous, Message-Driven Microservices
SVCC Developing Asynchronous, Message-Driven Microservices  SVCC Developing Asynchronous, Message-Driven Microservices
SVCC Developing Asynchronous, Message-Driven Microservices
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
 
Budget Proposal Template PowerPoint Presentation Slides
Budget Proposal Template PowerPoint Presentation SlidesBudget Proposal Template PowerPoint Presentation Slides
Budget Proposal Template PowerPoint Presentation Slides
 
Data.com APIs in Action ? Bringing Data to Life in Salesforce
Data.com APIs in Action ? Bringing Data to Life in SalesforceData.com APIs in Action ? Bringing Data to Life in Salesforce
Data.com APIs in Action ? Bringing Data to Life in Salesforce
 
Agados-based Application Design Demo
Agados-based Application Design Demo Agados-based Application Design Demo
Agados-based Application Design Demo
 
Building Competing Models Using Apache Spark DataFrames with Abdulla Al-Qawasmeh
Building Competing Models Using Apache Spark DataFrames with Abdulla Al-QawasmehBuilding Competing Models Using Apache Spark DataFrames with Abdulla Al-Qawasmeh
Building Competing Models Using Apache Spark DataFrames with Abdulla Al-Qawasmeh
 

More from Anna Mathis

Where do Citizens Go in Las Vegas (Bayesian Method Monte Carlo)
Where do Citizens Go in Las Vegas (Bayesian Method Monte Carlo)Where do Citizens Go in Las Vegas (Bayesian Method Monte Carlo)
Where do Citizens Go in Las Vegas (Bayesian Method Monte Carlo)Anna Mathis
 
Hire verses Overtime Analysis
Hire verses Overtime AnalysisHire verses Overtime Analysis
Hire verses Overtime AnalysisAnna Mathis
 
CostBenefitAnalysis
CostBenefitAnalysisCostBenefitAnalysis
CostBenefitAnalysisAnna Mathis
 
Example Performance Report
Example Performance ReportExample Performance Report
Example Performance ReportAnna Mathis
 
All About Companies
All About CompaniesAll About Companies
All About CompaniesAnna Mathis
 
Mathematical Formula to Find Net Premium
Mathematical Formula to Find Net PremiumMathematical Formula to Find Net Premium
Mathematical Formula to Find Net PremiumAnna Mathis
 

More from Anna Mathis (7)

Where do Citizens Go in Las Vegas (Bayesian Method Monte Carlo)
Where do Citizens Go in Las Vegas (Bayesian Method Monte Carlo)Where do Citizens Go in Las Vegas (Bayesian Method Monte Carlo)
Where do Citizens Go in Las Vegas (Bayesian Method Monte Carlo)
 
Hire verses Overtime Analysis
Hire verses Overtime AnalysisHire verses Overtime Analysis
Hire verses Overtime Analysis
 
CostBenefitAnalysis
CostBenefitAnalysisCostBenefitAnalysis
CostBenefitAnalysis
 
Example Performance Report
Example Performance ReportExample Performance Report
Example Performance Report
 
All About Companies
All About CompaniesAll About Companies
All About Companies
 
Kanban Queue
Kanban QueueKanban Queue
Kanban Queue
 
Mathematical Formula to Find Net Premium
Mathematical Formula to Find Net PremiumMathematical Formula to Find Net Premium
Mathematical Formula to Find Net Premium
 

Portfolio

  • 1. KPI looking at Billable hours as a trend, a single team and analysis on types of time off. This provides statistics that were used by executives and board members.
  • 2. Dashboard Examples: VSO – Visual Studios Online Using Power BI and importing data from Zen Desk to discover Support Ticket Trends.
  • 3. Obtain Next AvailableWO WO has a Number? WO will not be sent Create WO with Provided Template Select Project Management Group Create WO Entry in Site Select Work Orders Board Client Exists? HaveWO Admin Add Client Add Name of WO Fill Out WO#, WO Date, Quote & Deposit Upload WO Add Task to Correct Client Send out WO via Email to Client Create pdf of WO Send WO to Client for Approval Signatures Retrieve Necessary Client Signature Page Signed WO? NO YES No Work Order Retrieve Signed Signature Page CHSI Officer Sign the Signature Page Scan and Send Fully Signed WO to Client Upload pdf to Site and Connections UpdateDate Accepted field Verbally Declined WO not Accepted in Allotted # of Days Note Reason in Site Archive the Task NO WO Invoice Amount? Retrieve Invoice # in Site 50% Deposit Required Notify Accounting of Amt No deposit Signed WO can beScheduled Retrieve and Upload Document WO Greater than $5000 WO Less than $5000 Accounting fill in Required Fields Deposit Received Signed WO can beScheduled Work Order Updated UpdateWO Status & Fields in Site UpdateFields WO Admin Performs Data Dump Notify Accounting to Perform Final Billing Email Signed WO to Accounting w/ Amt Billed Accounting Updates Information Final Invoice # Sent Final Amt Rcvd NO YES YES WORK ORDER PROCESS
  • 4. This report was created to show the Written Premium by Policy Number grouped by Agency.
  • 5. The T-SQL below showcases how to I used declared variables and functions like case statements, subqueries, row_number(),first_value() and last_value() DECLARE @AsOfDate Date, @GroupName varchar(20) SET @AsOfDate = '6/30/2015' SET @GroupName = 'FBIM' SELECT clients.clientid, clients.clientname, clients.GroupID, clients.ClientType, [ContactInfo].contactname, CASE WHEN [ProducerClients].producername is null THEN 'No Producer Name Available' ELSE [ProducerClients].producername END [producername], [ProducerClients].Address1, [ProducerClients].Address2, [ProducerClients].city, [ProducerClients].State, [ProducerClients].zip, CASE WHEN ([ProducerClients].Address2 = '' OR [ProducerClients].Address2 IS NULL) THEN [ProducerClients].Address1 + CHAR(13) + CHAR(10) + [ProducerClients].city + ', ' + [ProducerClients].State + ' ' + [ProducerClients].zip ELSE [ProducerClients].Address1 + CHAR(13) + CHAR(10) + [ProducerClients].Address2 + CHAR(13) + CHAR(10) + [ProducerClients].city + ', ' + [ProducerClients].State + ' ' + [ProducerClients].zip END ProducerAddress, [ProducerClients].phone AS Phone, CASE WHEN [ProducerClients].taxpayerid is null THEN 'No id' WHEN [ProducerClients].taxpayerid = '' THEN 'No id' ELSE [ProducerClients].taxpayerid END taxpayerid, ROUND([Calculations].[Writtenpremium],2) WrittenPremium, [UWQuotes].policynumber, Uwquotes.policyperiod [UWPoliyPeriod], [ProducerClients].policyperiod [ProducerClientsPolicyPeriod], CAST([UWQuotes].effectivedate AS DATE) EffectiveDate, CAST(MONTH([UWQuotes].effectivedate) AS VARCHAR(2)) + '/' + CAST(DAY([UWQuotes].effectivedate) AS VARCHAR(2))+ '/' + CAST(YEAR([UWQuotes].effectivedate) AS VARCHAR(4)) [FormatEffectDate], CAST([UWQuotes].expirationdate AS DATE) ExpirationDate, DATENAME(dw,CAST(GetDate() AS DATETIME)) + ', ' + DATENAME(month,CAST(GETDATE() AS datetime)) + ' ' + DATENAME(day,CAST(GETDATE() AS datetime)) + ', ' + DATENAME(year, CAST(GETDATE() AS datetime)) PrintDate ,uwquotes.QuoteRow ,uwquotes.createtmsp ,uwquotes.quotetype ,uwquotes.quoteid FROM clients LEFT JOIN (SELECT contacts.contactid, contactname, clientcontacts.clientid, row_number() OVER (PARTITION BY clientcontacts.clientid ORDER BY CASE WHEN PrimaryContact = 'Y' THEN getdate() ELSE contacts.updatetmsp END DESC) rownumber FROM contacts INNER JOIN ClientContacts ON contacts.contactid = clientcontacts.contactid WHERE contacts.STATUS = 'active' AND clientcontacts.STATUS = 'active') [ContactInfo] ON contactinfo.clientid = clients.clientid AND contactinfo.rownumber = 1 CROSS APPLY (SELECT ISNULL(parentquote.policynumber, uwquotes.policynumber) [PolicyNumber] , uwquotes.effectivedate , uwquotes.expirationdate , uwquotes.quoteid , uwquotes.clientid , uwquotes.policyperiod , uwquotes.quotetype , uwquotes.status ,uwquotes.createtmsp , ROW_NUMBER() OVER (PARTITION BY uwquotes.policyperiod, uwquotes.clientid ORDER BY uwquotes.quotetype DESC, uwquotes.quotedate DESC, uwquotes.createtmsp DESC, (CASE WHEN uwquotes.parentquoteid IS NULL THEN uwquotes.quoteid ELSE uwquotes.parentquoteid END) DESC, uwquotes.policyperiod DESC) [QuoteRow] ,uwquotes.parentquoteid FROM uwquotes LEFT JOIN uwquotes [parentQuote] on uwquotes.parentquoteid = parentQuote.quoteid WHERE uwquotes.clientid = clients.clientid AND (@AsOfDate >= CAST([UWQuotes].effectivedate as date) AND ((@AsOfDate < [UWQuotes].expirationdate) OR [UWQuotes].expirationdate IS NULL)) AND uwquotes.STATUS = 'FINAL' AND uwquotes.quotetype IN ('CHSI1','Endrse','WCAudit') AND EXISTS (SELECT * FROM uwquotepremiumcalc WHERE quoteid = uwquotes.quoteid) AND ((CASE WHEN uwquotes.parentquoteid IS NULL THEN uwquotes.quoteid ELSE uwquotes.ParentQuoteID END) NOT IN (SELECT quoteid FROM [ClientCancellation] WHERE status = 'Cancelled'))) [uwquotes] LEFT JOIN (SELECT ClientCommissionsProducers.ProducerID, ClientCommissionsProducers.policyperiod, dbo.ClientHierarchy.clientid, dbo.ClientHierarchy.clientnumber, dbo.ClientHierarchy.relatedclientnumber, dbo.ClientHierarchy.topmostclientnumber, dbo.ClientHierarchy.Depth, isnull(childfilter.specvalue, 0) [ChildFilter], ClientCommissionsProducers.quoteid producers.producername, producers.Address1, producers.Address2, producers.city, producers.State, producers.zip, producers.phone, producers.taxpayerid FROM dbo.ClientHierarchy INNER JOIN (SELECT producerID, ClientID, effectiveDate, ExpirationDate, policyperiod, ROW_NUMBER() OVER (PARTITION BY producerid, clientid, policyperiod ORDER BY quoteid DESC, effectivedate DESC, policyperiod DESC) [Row], clientcommissions.quoteid FROM clientcommissions WHERE status <> 'deleted') [ClientCommissionsProducers] ON Row = 1 AND ClientCommissionsProducers.clientid = ClientHierarchy.clientid INNER JOIN clients ON clients.ClientID = ClientCommissionsProducers.clientid LEFT OUTER JOIN dbo.GroupSpecs AS ChildFilter ON ChildFilter.GroupName = clients.groupid AND ChildFilter.SpecName = 'ChildUserFilterByComissions' LEFT OUTER JOIN dbo.GroupSpecs AS DenyExpiredAccess ON DenyExpiredAccess.GroupName = clients.groupid AND DenyExpiredAccess.SpecName ='DenyBrkerAcctoExpCom' INNER JOIN Producers ON Producers.ProducerID = [ClientCommissionsProducers].ProducerID WHERE (GETDATE() <= ClientCommissionsProducers.expirationdate OR ISNULL(denyexpiredaccess.specvalue,0) = 1) ) [ProducerClients] ON (ProducerClients.ClientID = clients.clientid) AND (CASE WHEN uwquotes.parentquoteid IS NULL THEN uwquotes.quoteid ELSE uwquotes.parentquoteid END)=[ProducerClients].quoteid INNER JOIN (SELECT quoteid, SUM (CASE WHEN modid = firstmod THEN resultamount ELSE 0 END) [Manualpremium], SUM (CASE WHEN modid = lastmod THEN resultamount ELSE 0 END) [Writtenpremium] FROM (SELECT uwquotepremiumcalc.resultamount, uwquotepremiumcalc.quoteid, assessmentmods.modid, FIRST_VALUE( uwquotepremiumcalc.modid) OVER (PARTITION BY uwquotepremiumcalc.quoteid ORDER BY assessmentmods.sortorder ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) [firstmod], LAST_VALUE(uwquotepremiumcalc.modid) OVER (PARTITION BY uwquotepremiumcalc.quoteid ORDER BY assessmentmods.sortorder ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) [lastmod] FROM assessmentmods INNER JOIN uwquotepremiumcalc ON assessmentmods.modid = uwquotepremiumcalc.modid WHERE resultamount <> 0 ) [QuoteModValues] GROUP BY quoteid) [Calculations] ON Calculations.quoteid = uwquotes.quoteid WHERE clients.groupid = @GroupName AND (@AsOfDate >= CAST([UWQuotes].effectivedate as date) AND ((@AsOfDate < [UWQuotes].expirationdate) OR [UWQuotes].expirationdate IS NULL)) AND ([ProducerClients].policyperiod = Uwquotes.policyperiod OR [ProducerClients].policyperiod IS NULL) AND [UWQuotes].effectivedate <> [UWQuotes].expirationdate AND uwquotes.QuoteRow = 1 ORDER BY Clients.clientname
  • 6. This report is showing the contributions, itemized in each type of liability that this customer provides. The report will only show one quote id. This was done using the SQL function: Pivots
  • 7. declare @QuoteID int set @QuoteID = 1 Select * from (select dbo.clientswithParentOrg.ClientName, dbo.clientswithParentOrg.clientid, dbo.clientswithParentOrg.billingaddress1, dbo.clientswithParentOrg.billingaddress2, dbo.clientswithParentOrg.billingcity, dbo.clientswithParentOrg.billingstate, dbo.clientswithParentOrg.billingzip, UWQuotes.QuoteID, UWQuotes.PolicyPeriod, Datename(Month,UWQuotes.EffectiveDate) + Right(Convert(varchar(12),UWQuotes.EffectiveDate,107),9) EffectiveDate, Datename(Month,UWQuotes.ExpirationDate) + Right(Convert(varchar(12),UWQuotes.ExpirationDate,107),9) ExpirationDate, UWQuotes.PolicyNumber, UWQuoteTypes.QTName, program.programname, coverageline.CoverageLine, ProgramRate.ratename, programratedetail.VariableName RateDetailVariableName, programratevariable.VariableName ProgramRateVariableName, choose(programratevariable.DataType, quoteratevariable.stringvalue, convert(varchar, quoteratevariable.datevalue, 101), convert(varchar, quoteratevariable.decimalvalue), convert(varchar,quoteratevariable.boolvalue), convert(varchar, quoteratevariable.integervalue)) QuoteVariableValue from (dbo.UWQuotes UWQuotes inner join (dbo.UWQuoteTypes UWQuoteTypes inner join uw.program program on program.programname = UWQuoteTypes.qtname) on UWQuoteTypes.qtname = UWQuotes.quotetype inner join (uw.QuoteCoverageLine QuoteCoverageLine inner join uw.coverageline coverageline on QuoteCoverageLine.CoverageLineID = coverageline.coveragelineid inner join uw.ProgramRate ProgramRate on ProgramRate.Coveragelineid = coverageline.coveragelineid) on UWQuotes.QuoteID = QuoteCoverageLine.QuoteID inner join ([UW].[QuoteRateInfo] [QuoteRateInfo] inner join uw.programratedetail programratedetail on programratedetail.RateDetailID = [QuoteRateInfo].RateDetailID inner join ((select *, max(historyindex) over (partition by programratevariableid, rateinfoid) MaxHistoryIndex from uw.quoteratevariable) quoteratevariable inner join uw.programratevariable programratevariable on programratevariable.programratevariableid = quoteratevariable.programratevariableid and quoteratevariable.HistoryIndex = quoteratevariable.MaxHistoryIndex ) on quoteratevariable.rateinfoid = [QuoteRateInfo].rateinfoid ) on [QuoteRateInfo].quoteid = UWQuotes.quoteid and [QuoteRateInfo].coveragelineid = QuoteCoverageLine.coveragelineid) inner join dbo.clientswithParentOrg on clientswithParentOrg.clientid = UWQuotes.clientid where UWQuotes.QuoteID = @QuoteID ) Source Pivot(Max(QuoteVariableValue) for ProgramRateVariableName in (LELPOLPremium,Premium,Rate,EffectiveRate,HazardCount,Limit) ) as pvt
  • 8. This report looks at the past 30 days of all policies and states the several calculated fields using SQL and Crystal Report formatting. The SQL utilitized the following functions: A Declared Table, IsNull, an Inner Join with a Pivot inside and subqueries. This report will render over 20 pages in SAP Crystal in under 5 seconds.
  • 9. This SQL Query showcases my usage of table variables and the Pivot Function. DECLARE @GroupName VARCHAR(20) = 'FBIM' DECLARE @Payments TABLE (CountofPayments INT, Payments INT, PaidToDate INT, ClientID INT, PolicyPeriod INT, AvgPayments INT, AnnualizedPmts INT) INSERT INTO @Payments SELECT *, [AvgPayments]*12 [AnnualizedPmts] FROM (SELECT *, CASE WHEN BulkData.[CountofPayments] = 0 THEN 0 ELSE CAST(ROUND((BulkData.[PaidToDate]/BulkData.[CountofPayments]),0) AS INT) END [AvgPayments] FROM (SELECT SUM(CASE WHEN creditamount = 0 THEN 0 ELSE 1 END) [CountofPayments], COUNT(creditamount) [payments], SUM(creditamount) [PaidToDate], clientid, PolicyPeriod FROM [dbo].[AcctsRecvLog] WHERE AccountNo in ('FB001','FB004') AND YEAR(GETDATE()) = policyperiod AND YEAR(GETDATE()) = YEAR(DateReceived) AND GETDATE() >= DateReceived GROUP BY Clientid, PolicyPeriod ) BULKDATA ) [AvgPayments] SELECT *, CASE WHEN [WrittenPremium] is NULL THEN 0-AnnualizedPmts ELSE [WrittenPremium]-AnnualizedPmts END [Difference] FROM (SELECT clients.clientid, clients.clientname, clients.GroupID, CAST(ROUND([PivotUWQuoteDetail].AnnualPremium,0) as INT) [EstAnnual], CAST(ROUND([PivotUWQuoteDetail].WrittenPremium,0) as INT) [WrittenPremium], [UWQuotes].policynumber, [Uwquotes].quoteid, CAST([UWQuotes].effectivedate as DATE) EffectiveDate, CAST(MONTH([UWQuotes].effectivedate) as VARCHAR(2)) + '/' + CAST(DAY([UWQuotes].effectivedate) as VARCHAR(2)) + '/' + CAST(YEAR([UWQuotes].effectivedate) as VARCHAR(4))[FormatEffectDate], CAST([UWQuotes].expirationdate as DATE) ExpirationDate, CAST(MONTH([UWQuotes].expirationdate) as VARCHAR(2)) + '/' + CAST(DAY([UWQuotes].expirationdate) as VARCHAR(2)) + '/' + CAST(YEAR([UWQuotes].expirationdate) as VARCHAR(4))[FormatExpireDate], CASE WHEN [payments].[CountofPayments] is NULL THEN 0 ELSE [payments].[CountofPayments] END [CountofPayments], CASE WHEN [payments].[PaidToDate] is NULL THEN 0 ELSE [payments].[PaidToDate] END [PaidToDate], [payments].AvgPayments, [payments].AnnualizedPmts, ISNULL(ClientGroups.LongName, Clients.GroupID) [LongName] FROM clients INNER JOIN (SELECT Longname, GroupName FROM [dbo].[ClientGroups] WHERE ClientGroups.Status = 'Active') [ClientGroups] ON Clients.Groupid = [ClientGroups].GroupName INNER JOIN (SELECT DISTINCT dbo.ClientHierarchy.clientid, dbo.ClientHierarchy.clientnumber, dbo.ClientHierarchy.relatedclientnumber, dbo.ClientHierarchy.topmostclientnumber, dbo.ClientHierarchy.Depth, isnull(childfilter.specvalue, 0) [ChildFilter] FROM dbo.ClientHierarchy INNER JOIN (SELECT ClientID, effectiveDate, ExpirationDate, ROW_NUMBER() OVER (PARTITION BY producerid, clientid ORDER BY effectivedate DESC) [Row] FROM clientcommissions WHERE status <> 'deleted') [ClientCommissionsProducers] ON Row = 1 and ClientCommissionsProducers.clientid = ClientHierarchy.clientid INNER JOIN clients on clients.ClientID = ClientCommissionsProducers.clientid LEFT OUTER JOIN dbo.GroupSpecs AS ChildFilter ON ChildFilter.GroupName = clients.groupid AND ChildFilter.SpecName = 'ChildUserFilterByComissions' LEFT OUTER JOIN dbo.GroupSpecs AS DenyExpiredAccess ON DenyExpiredAccess.GroupName = clients.groupid AND DenyExpiredAccess.SpecName = 'DenyBrokerAccesstoExpiredCommissions' WHERE GETDATE() <= ClientCommissionsProducers.expirationdate OR ISNULL(denyexpiredaccess.specvalue,0) = 1) [ProducerClients] ON (ProducerClients.ClientID = clients.clientid) INNER JOIN (SELECT uwquotes.policynumber, uwquotes.effectivedate, uwquotes.expirationdate, uwquotes.quoteid, uwquotes.clientid, uwquotes.policyperiod , uwquotes.quotetype FROM uwquotes WHERE status = 'FINAL' AND quotetype = 'CHSI1') [UWQuotes] ON UWQuotes.clientid = Clients.clientid INNER JOIN (SELECT DISTINCT QuoteID, [85] as AnnualPremium, [86] as WrittenPremium FROM (SELECT QuoteID, FieldID, FieldValue FROM dbo.uwquotedetail WHERE FieldID in (86,85) ) AS Src PIVOT (MAX(Fieldvalue) FOR FieldID IN ([86],[85]) ) AS QDPivot) [PivotUWQuoteDetail] ON uwquotes.QuoteID = [PivotUWQuoteDetail].QuoteID INNER JOIN @Payments [Payments] ON [Payments].Clientid = Clients.clientid LEFT JOIN (SELECT ClientID, QuoteId, Status, CancellationDate FROM ClientCancellation WHERE cancellationDate <= CAST(GETDATE() as DATE) AND cancellationdate >= CAST(DATEADD(day, -30, GETDATE()) as date) AND [ReinstatementDate] is NULL AND [RescissionDate] is NULL) [ClientCancellation] ON [ClientCancellation].clientid = Clients.clientid AND [ClientCancellation].quoteid = [UWQuotes].quoteid ) BulkData WHERE BulkData.groupid = @GroupName AND CAST(GETDATE() as date) >= EffectiveDate AND CAST(GETDATE() as date) <= ExpirationDate ORDER BY [Difference]