SlideShare une entreprise Scribd logo
1  sur  1
--------------------------------------------------------------------------------
------------
DECLARE @startdate DATETIME
DECLARE @enddate DATETIME
DECLARE @id INT
DECLARE @totalcount INT
DECLARE @StartCounter INT = 1
DECLARE @BillDetailNormalized TABLE
(
ID INT,
StartDate DATETIME,
EndDate DATETIME
)
SELECT @totalcount = MAX(BillDetailID) from TempBillDetail
SET @StartCounter = 1
WHILE (@StartCounter <=@totalcount) --Total Records Loop
BEGIN
SELECT @startdate = StartDate,@enddate = EndDate FROM TempBillDetail WHERE
BillDetailID= @StartCounter
WHILE (DATEPART(MM,@startdate) <= DATEPART(MM,@enddate))-- Start Date and
EndDate Loop
BEGIN
IF (DATEPART(MM,@startdate) = DATEPART(MM,@enddate))
INSERT INTO @BillDetailNormalized VALUES (@StartCounter, @startdate,@enddate)
ELSE IF (DATEPART(MM,@startdate) < DATEPART(MM,@enddate))
INSERT INTO @BillDetailNormalized VALUES (@StartCounter,
@startdate,EOMONTH(@STARTDATE))
SET @startdate = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@startdate)+1,0)) +1
END
SET @StartCounter = @StartCounter + 1
END
--------------------------------------------------------------------------------
---------------
DECLARE @ServiceBeginKey DATE= '2013-11-01'
DECLARE @ServiceEndKey DATE = '2014-10-31'
SELECT * from ClientFiscalPeriods c WHERE ClientKey = 9
AND (C.FiscalPeriodCalendarEndDateKey >= @ServiceBeginKey)
AND (C.FiscalPeriodCalendarBeginDateKey <= @ServiceEndKey)
--------------------------------------------------------------------------------
---------------

Contenu connexe

En vedette (10)

Dlaznostna harakteristika Enemona - 2015 Expert BG
Dlaznostna harakteristika Enemona - 2015 Expert BGDlaznostna harakteristika Enemona - 2015 Expert BG
Dlaznostna harakteristika Enemona - 2015 Expert BG
 
The Virtual Team Challenge
The Virtual Team ChallengeThe Virtual Team Challenge
The Virtual Team Challenge
 
Use Physiological Monitoring to Improve Training Assessment
Use Physiological Monitoring to Improve Training AssessmentUse Physiological Monitoring to Improve Training Assessment
Use Physiological Monitoring to Improve Training Assessment
 
Edit
EditEdit
Edit
 
Ikram english.cv
Ikram english.cvIkram english.cv
Ikram english.cv
 
Distracted Driving_2017JAN
Distracted Driving_2017JANDistracted Driving_2017JAN
Distracted Driving_2017JAN
 
Avvo fkafka
Avvo fkafkaAvvo fkafka
Avvo fkafka
 
บทที่1
บทที่1บทที่1
บทที่1
 
Fiesta de Navidad
Fiesta de NavidadFiesta de Navidad
Fiesta de Navidad
 
Sony
SonySony
Sony
 

Similaire à Df

Queries assignment udf_and_triggers
Queries assignment udf_and_triggersQueries assignment udf_and_triggers
Queries assignment udf_and_triggers
Priya Sharma
 
Metadata Matters
Metadata MattersMetadata Matters
Metadata Matters
afa reg
 
T sql denali code Day of .Net
T sql denali code Day of .NetT sql denali code Day of .Net
T sql denali code Day of .Net
KathiK58
 
Seistech SQL code
Seistech SQL codeSeistech SQL code
Seistech SQL code
Simon Hoyle
 
Paging storedprocedure
Paging storedprocedurePaging storedprocedure
Paging storedprocedure
seethalux
 
Organic Gardens SQL Database Schema By Christopher Kaczor
Organic Gardens SQL Database Schema By Christopher KaczorOrganic Gardens SQL Database Schema By Christopher Kaczor
Organic Gardens SQL Database Schema By Christopher Kaczor
Christopher Kaczor
 
Mdp plus 2.1
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1
boedax
 
[INSIGHT OUT 2011] B24 effective indexing(tom kyte)
[INSIGHT OUT 2011] B24 effective indexing(tom kyte)[INSIGHT OUT 2011] B24 effective indexing(tom kyte)
[INSIGHT OUT 2011] B24 effective indexing(tom kyte)
Insight Technology, Inc.
 

Similaire à Df (20)

DECLARE example
DECLARE exampleDECLARE example
DECLARE example
 
Queries assignment udf_and_triggers
Queries assignment udf_and_triggersQueries assignment udf_and_triggers
Queries assignment udf_and_triggers
 
Add invoice
Add invoiceAdd invoice
Add invoice
 
SAV
SAVSAV
SAV
 
Metadata Matters
Metadata MattersMetadata Matters
Metadata Matters
 
How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012
 
T sql denali code Day of .Net
T sql denali code Day of .NetT sql denali code Day of .Net
T sql denali code Day of .Net
 
Seistech SQL code
Seistech SQL codeSeistech SQL code
Seistech SQL code
 
MK1_Addendum
MK1_AddendumMK1_Addendum
MK1_Addendum
 
MariaDB Temporal Tables
MariaDB Temporal TablesMariaDB Temporal Tables
MariaDB Temporal Tables
 
as400 built in function- %MINUTES
as400 built in function- %MINUTESas400 built in function- %MINUTES
as400 built in function- %MINUTES
 
as400 built in function- %SECONDS
as400 built in function- %SECONDSas400 built in function- %SECONDS
as400 built in function- %SECONDS
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
Paging storedprocedure
Paging storedprocedurePaging storedprocedure
Paging storedprocedure
 
Organic Gardens SQL Database Schema By Christopher Kaczor
Organic Gardens SQL Database Schema By Christopher KaczorOrganic Gardens SQL Database Schema By Christopher Kaczor
Organic Gardens SQL Database Schema By Christopher Kaczor
 
as400 built in function- %HOURS
as400 built in function- %HOURSas400 built in function- %HOURS
as400 built in function- %HOURS
 
Mdp plus 2.1
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1
 
[INSIGHT OUT 2011] B24 effective indexing(tom kyte)
[INSIGHT OUT 2011] B24 effective indexing(tom kyte)[INSIGHT OUT 2011] B24 effective indexing(tom kyte)
[INSIGHT OUT 2011] B24 effective indexing(tom kyte)
 
JKJ_T SQL project code samples
JKJ_T SQL project code samplesJKJ_T SQL project code samples
JKJ_T SQL project code samples
 
Writeable CTEs: The Next Big Thing
Writeable CTEs: The Next Big ThingWriteable CTEs: The Next Big Thing
Writeable CTEs: The Next Big Thing
 

Dernier

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Dernier (20)

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 

Df

  • 1. -------------------------------------------------------------------------------- ------------ DECLARE @startdate DATETIME DECLARE @enddate DATETIME DECLARE @id INT DECLARE @totalcount INT DECLARE @StartCounter INT = 1 DECLARE @BillDetailNormalized TABLE ( ID INT, StartDate DATETIME, EndDate DATETIME ) SELECT @totalcount = MAX(BillDetailID) from TempBillDetail SET @StartCounter = 1 WHILE (@StartCounter <=@totalcount) --Total Records Loop BEGIN SELECT @startdate = StartDate,@enddate = EndDate FROM TempBillDetail WHERE BillDetailID= @StartCounter WHILE (DATEPART(MM,@startdate) <= DATEPART(MM,@enddate))-- Start Date and EndDate Loop BEGIN IF (DATEPART(MM,@startdate) = DATEPART(MM,@enddate)) INSERT INTO @BillDetailNormalized VALUES (@StartCounter, @startdate,@enddate) ELSE IF (DATEPART(MM,@startdate) < DATEPART(MM,@enddate)) INSERT INTO @BillDetailNormalized VALUES (@StartCounter, @startdate,EOMONTH(@STARTDATE)) SET @startdate = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@startdate)+1,0)) +1 END SET @StartCounter = @StartCounter + 1 END -------------------------------------------------------------------------------- --------------- DECLARE @ServiceBeginKey DATE= '2013-11-01' DECLARE @ServiceEndKey DATE = '2014-10-31' SELECT * from ClientFiscalPeriods c WHERE ClientKey = 9 AND (C.FiscalPeriodCalendarEndDateKey >= @ServiceBeginKey) AND (C.FiscalPeriodCalendarBeginDateKey <= @ServiceEndKey) -------------------------------------------------------------------------------- ---------------