You are on page 1of 5

/****** Script for SelectTopNRows command from SSMS ******/

SELECT TOP 1000 [ETLBatchID]


,[PPN_DT]
,[STAGE_AUDIT_KEY]
,[FileName]
,[SerialNo]
,[SubSequence]
,[TimeStamp]
,[ServiceKey]
,[CallingPartyNumber]
,[CalledPartyNumber]
,[CallingPartyIMSI]
,[CalledPartyIMSI]
,[DialedNumber]
,[OriginalCalledParty]
,[ServiceFlow]
,[CallForwardIndicator]
,[CallingRoamInfo]
,[CallingCellID]
,[CalledRoamInfo]
,[CalledCellID]
,[TimeStampOfSSP]
,[TimeZoneOfSSP]
,[BearerCapability]
,[BearerCapability2]
,[ChargingTime]
,[WaitDuration]
,[CallDuration]
,[TerminationReason]
,[CallReferenceNumber]
,[IMEI]
,[ChargeDuration]
,[AccessPrefix]
,[RoutingPrefix]
,[RedirectingPartyID]
,[BrandID]
,[SubCOSID]
,[ChargingPartyNumber]
,[ChargePartyIndicator]
,[PayType]
,[BillCycleID]
,[ChargingType]
,[CallType]
,[RoamState]
,[ResultCode]
,[FPHPrefix]
,[CallingHomeCountryCode]
,[CallingHomeAreaNumber]
,[CallingHomeNetworkCode]
,[CallingRoamCountryCode]
,[CallingRoamAreaNumber]
,[CallingRoamNetworkCode]
,[CalledHomeCountryCode]
,[CalledHomeAreaNumber]
,[CalledHomeNetworkCode]
,[CalledRoamCountryCode]
,[CalledRoamAreaNumber]
,[CalledRoamNetworkCode]
,[ProductID]
,[ServiceType]
,[HotLineIndicator]
,[HomeZoneID]
,[NPFlag]
,[NPPrefix]
,[CallingGroupNo]
,[CalledGroupNo]
,[UserState]
,[SubscriberID]
,[OpposeNumberType]
,[SameBrandPre]
,[ChargeOfItemsAccounts]
,[ChargeOfDurationAccounts]
,[ChargeOfFundAccounts]
,[ChargeFromPrepaid]
,[PrepaidBalance]
,[ChargeFromPostpaid]
,[PostPaidBalance]
,[AccountID]
,[AccountKey]
,[CurrencyCode]
,[FNGroup]
,[AccountType1]
,[FeeType1]
,[ChargeAmount1]
,[CurrentAcctAmount1]
,[AccountType2]
,[FeeType2]
,[ChargeAmount2]
,[CurrentAcctAmount2]
,[AccountType3]
,[FeeType3]
,[ChargeAmount3]
,[CurrentAcctAmount3]
,[AccountType4]
,[FeeType4]
,[ChargeAmount4]
,[CurrentAcctAmount4]
,[AccountType5]
,[FeeType5]
,[ChargeAmount5]
,[CurrentAcctAmount5]
,[AccountType6]
,[FeeType6]
,[ChargeAmount6]
,[CurrentAcctAmount6]
,[AccountType7]
,[FeeType7]
,[ChargeAmount7]
,[CurrentAcctAmount7]
,[AccountType8]
,[FeeType8]
,[ChargeAmount8]
,[CurrentAcctAmount8]
,[AccountType9]
,[FeeType9]
,[ChargeAmount9]
,[CurrentAcctAmount9]
,[AccountType10]
,[FeeType10]
,[ChargeAmount10]
,[CurrentAcctAmount10]
,[BonusValidity1]
,[BonusValidity2]
,[BonusValidity3]
,[BonusValidity4]
,[BonusValidity5]
,[BonusValidity6]
,[BonusValidity7]
,[BonusValidity8]
,[BonusValidity9]
,[BonusValidity10]
,[CallingVPNTopGroupNumber]
,[CallingVPNGroupNumber]
,[CallingVPNShortNumber]
,[CalledVPNTopGroupNumber]
,[CalledVPNGroupNumber]
,[CalledVPNShortNumber]
,[CallingNetworkType]
,[CalledNetworkType]
,[GroupCallType]
,[GroupPayFlag]
,[OnlineType]
,[Reserved2]
,[Reserved3]
,[Reserved4]
,[Reserved5]
,[AddtionaInfo]
,[StartTimeOfBillCycle]
,[SecondChargingPartyNumber]
,[SecondChargingPartyPayType]
,[SecondChargingPartyBillCycleID]
,[ChargeOfItemsSecondAccounts]
,[ChargeOfDurationSecondAccounts]
,[ChargeOfFundSecondAccounts]
,[ChargeFromSecondPrepaidAccount]
,[SecondPrepaidAccountBalance]
,[ChargeFromSecondPostpaidAccount]
,[SecondPostpaidAccountBalance]
,[SecondAccountID]
,[SecondAccountKey]
,[SecondAccountCurrencyCode]
,[Reserved7]
,[SecondAccountType1]
,[SecondFeeType1]
,[SecondChargeAmount1]
,[SecondCurrentAcctAmount1]
,[SecondAccountType2]
,[SecondFeeType2]
,[SecondChargeAmount2]
,[SecondCurrentAcctAmount2]
,[SecondAccountType3]
,[SecondFeeType3]
,[SecondChargeAmount3]
,[SecondCurrentAcctAmount3]
,[SecondAccountType4]
,[SecondFeeType4]
,[SecondChargeAmount4]
,[SecondCurrentAcctAmount4]
,[SecondAccountType5]
,[SecondFeeType5]
,[SecondChargeAmount5]
,[SecondCurrentAcctAmount5]
,[SecondBonusValidity1]
,[SecondBonusValidity2]
,[SecondBonusValidity3]
,[SecondBonusValidity4]
,[SecondBonusValidity5]
,[CallingClusterNumber]
,[CalledClusterNumber]
,[OriginalCallingParty]
,[PulaPulaProperty]
,[BumerangeProperty]
,[OppositePartyNumber]
,[RegionalZoneID]
,[DestinationName]
,[RateName]
,[DiameterSessionID]
,[StartcountryGroup]
,[EndcountryGroup]
,[usergrade]
,[IsTestNumber]
,[MainProductStatus]
,[SubscriberIDType]
,[OriginatingIOI]
,[TerminatingIOI]
,[IMSChargingIdentifier]
,[Pulse]
,[StartTimOfOCS]
,[DiscountOfLastEffProduct]
,[SubscriberKey]
,[AccumulationChange]
,[UsageServiceType]
,[SourceSerialNo]
,[SourceSubSequence]
,[AcctBalChgList]
,[SubscriberType]
,[OriginCdrFilename]
,[CurCDRLineNo]
,[DDSDiscountOff]
,[Tax]
,[Tax2]
,[Tax3]
,[Tax4]
,[SecondSubscriberKey]
,[SecondProductID]
,[SetupFee]
,[OpposeTenantID]
,[PreferAreaCellId]
,[ChargeWithoutTax]
,[MainAccountKey]
,[TapFilename]
,[ZoneInfoFlag]
,[ZoneType]
,[MSCAddress]
,[CircuitNo]
,[BalanceBeforeChargePOS]
,[ProductIDList]
,[ProductRateAmtList]
,[SecondBalanceBeforeCHargePOS]
,[UserNetworkType]
,[SerialNumber]
,[InnerCDRSequence]
,[OldAlloBalance]
,[NewAlloBalance]
,[DateEntered]
FROM [AnalyticsStaging].[dbo].[CBSREC]

select ppn_dt, count(*) as nbre, paytype, sum(chargeamount1)/100 as revenue,


sum(callduration) as duree--, SubCOSID,
into ##tempSIP
FROM [AnalyticsStaging].[dbo].[CBSREC] with (nolock)
where ppn_dt between '20181101' and '20181130'
and CalledPartyNumber in ('221201555', '201555')
group by PPN_DT, [PayType]

You might also like