0% found this document useful (0 votes)
228 views12 pages

Cognos Learning

The document contains SQL queries and scripts for various reporting and data management tasks. The queries retrieve user access and license data from a Cognos database, build monitoring data from process logs, and call result data from an ODS database. The scripts copy output files to network folders, rename files with date prefixes, and run Excel macros to rename sheets.

Uploaded by

sygladiator
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
228 views12 pages

Cognos Learning

The document contains SQL queries and scripts for various reporting and data management tasks. The queries retrieve user access and license data from a Cognos database, build monitoring data from process logs, and call result data from an ODS database. The scripts copy output files to network folders, rename files with date prefixes, and run Excel macros to rename sheets.

Uploaded by

sygladiator
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Groupwise cognos UserAccess Report

--------------------------------Query1------------------------------------------------

SELECT v_group.name as group_name, v_user.ldap_id

FROM Cognos11BIProdStore.dbo.cmreford1 as v_group_user

JOIN

(SELECT cmid user_id, UPPER (NAME) ldap_id FROM Cognos11BIProdStore.dbo.cmobjprops33

) v_user ON v_group_user.refcmid = v_user.user_id JOIN

(SELECT cmobjnames.cmid cmid, UPPER (cmobjnames.NAME) name FROM


Cognos11BIProdStore.dbo.cmobjects,

Cognos11BIProdStore.dbo.cmobjnames

WHERE --cmobjects.classid IN (26, 54) AND

--cmobjnames.mapdlocaleid = 96 and

cmobjects.cmid = cmobjnames.cmid

and cmobjnames.NAME not like '20%'

) v_group

ON v_group.cmid = v_group_user.cmid

where ldap_id<>'COGNOS'

order by 1,2

--------------------Query 2------------------------------------------------------------

SELECT v_group.name as group_name, count(v_user.ldap_id) as num_of_users

FROM Cognos11BIProdStore.dbo.cmreford1 as v_group_user

JOIN

(SELECT cmid user_id, UPPER (NAME) ldap_id FROM Cognos11BIProdStore.dbo.cmobjprops33

) v_user ON v_group_user.refcmid = v_user.user_id JOIN

(SELECT cmobjnames.cmid cmid, UPPER (cmobjnames.NAME) name FROM


Cognos11BIProdStore.dbo.cmobjects,

Cognos11BIProdStore.dbo.cmobjnames

WHERE --cmobjects.classid IN (26, 54) AND

cmobjnames.mapdlocaleid = 96 and
cmobjects.cmid = cmobjnames.cmid

and cmobjnames.NAME not like '20%'

) v_group

ON v_group.cmid = v_group_user.cmid

where ldap_id<>'COGNOS'

group by v_group.name

order by 1,2

-----------------------Multiple License Report---------------------------


SELECT v_user.ldap_id,v_group.name--v_group.name as group_name, v_user.ldap_id

FROM Cognos11BIProdStore.dbo.cmreford1 as v_group_user

JOIN

(SELECT cmid user_id, UPPER (NAME) ldap_id FROM Cognos11BIProdStore.dbo.cmobjprops33

) v_user ON v_group_user.refcmid = v_user.user_id JOIN

(SELECT cmobjnames.cmid cmid, UPPER (cmobjnames.NAME) name FROM


Cognos11BIProdStore.dbo.cmobjects,

Cognos11BIProdStore.dbo.cmobjnames

WHERE --cmobjects.classid IN (26, 54) AND cmobjnames.mapdlocaleid = 24 and

cmobjects.cmid = cmobjnames.cmid

) v_group

ON v_group.cmid = v_group_user.cmid

where ldap_id<>'COGNOS'

--and ldap_id ='SSHARMA5'

and v_group.name in ('PROFESSIONAL','ENHANCED CONSUMER','ADVANCED BUSINESS


AUTHOR','ADMINISTRATOR','Analytics Explorer','Analytics Information Distribution','Analytics User')

--group by v_user.ldap_id,v_group.name

order by 1--,2

----------------Report Schedule management Queries ---------------------


Select

RPT_SCHED_MGMT.PROCESSKEY ,
RPT_SCHED_MGMT.TSTAMP

From

[SQL_BIMARKET1].RPT_SCHED_MGMT RPT_SCHED_MGMT

Select

From

[OPS_BIDATA1].D_CALENDAR D_CALENDAR
-------------------------------Nightly Build Monitoring Report =-----------------------
--
Daily Activity Query :

SELECT "audit_id", "Build_name", "component_name", "Status", "component_type",


"start_timestamp", "end_timestamp", "duration_in_seconds", "component_uuid",

"table_name", "rows_inserted", "rows_updated", "existing_data","Index_Rebuild"

FROM "dbo"."dm_lg_process_daily_logs"

Failed Jobs :

SELECT "audit_id", "Build_name", "component_name", "Status", "component_type",


"start_timestamp", "end_timestamp", "duration_in_seconds", "component_uuid",
"table_name", "rows_inserted", "rows_updated", "existing_data",
"Index_Rebuild"

FROM "dbo"."dm_lg_process_daily_failed_logs"

where "component_name" not like 'DEV%'

Running Since >2 Hours

SELECT "audit_id", "Build_name", "component_name", "Status", "component_type",


"start_timestamp", "end_timestamp", "duration_in_seconds",
atediff("hh",getdate(),"start_timestamp")*-1 TotalHours_SinceRunning ,
atediff("mi",getdate(),"start_timestamp")*-1 TotalMinutes_SinceRunning, "component_uuid",
"table_name", "rows_inserted", "rows_updated", "existing_data",
"Index_Rebuild"FROM "dbo"."dm_lg_process_daily_running_logs"

where component_name not like '%MASTER_INCREMENTAL%'

and (Build_name+component_name <>'LOCheck DME Rollover')

and (Build_name+component_name<>'LORun DME Build')

and (Build_name+component_name<>'MarketingExecute All The Builds')

and (Build_name+component_name<>'MarketingRun LO Server builds')

and (component_name<>'Run Mkt SQL Server Build')

and (component_name<>'Run OPS SQL server build')

and datediff("mi",getdate(),"start_timestamp")*-1 >120


and Build_name <> '%DEV%'

Running Now :

SELECT "audit_id", "Build_name", "component_name", "Status", "component_type",


"start_timestamp", "end_timestamp", "duration_in_seconds", "component_uuid",
"table_name", "rows_inserted", "rows_updated", "existing_data",
"Index_Rebuild"

FROM "dbo"."dm_lg_process_daily_running_logs"

Copt Sheets to Another location Script


:begin

xcopy "E:\outputs\CCT Outputs\IO Dialer Production Report-en-us.xlsx" "\\phxiodfs01\Detailed


Collections\Dialer\2018\DPR" /Y
ren "\\phxiodfs01\Detailed Collections\Dialer\2018\DPR\IO Dialer Production Report-en-us.xlsx" "IO
Dialer Production Report_%date:~10,4%%date:~4,2%%date:~7,2%.xlsx"

xcopy "E:\outputs\CCT Outputs\HOST3 IO Dialer Production Report-en-us.xlsx" "\\phxiodfs01\Detailed


Collections\Dialer\2018\DPR\Host3 DPR" /Y
ren "\\phxiodfs01\Detailed Collections\Dialer\2018\DPR\Host3 DPR\HOST3 IO Dialer Production
Report-en-us.xlsx" "HOST3 IO Dialer Production Report_%date:~10,4%%date:~4,2%%date:~7,2%.xlsx"

xcopy "E:\outputs\CCT Outputs\IO Daily Dialer Report-en-us.xlsx" "\\phxiodfs01\Detailed


Collections\Dialer\2018\Daily Dialer Report" /Y
ren "\\phxiodfs01\Detailed Collections\Dialer\2018\Daily Dialer Report\IO Daily Dialer Report-en-
us.xlsx" "IO Daily Dialer Report_%date:~10,4%%date:~4,2%%date:~7,2%.xlsx"

xcopy "E:\outputs\CCT Outputs\Host3 IO Daily Dialer Report-en-us.xlsx" "\\phxiodfs01\Detailed


Collections\Dialer\2018\Daily Dialer Report\Host3 Daily Dailer Report" /Y
ren "\\phxiodfs01\Detailed Collections\Dialer\2018\Daily Dialer Report\Host3 Daily Dailer Report\Host3
IO Daily Dialer Report-en-us.xlsx" "Host3 IO Daily Dialer
Report_%date:~10,4%%date:~4,2%%date:~7,2%.xlsx"

exit
.bat file

Excel Macros to Rename the sheets in Excel

Sub namesheets()
On Error Resume Next
Application.ScreenUpdating = False
Dim ws As Workbook, pt As String
pt = ThisWorkbook.Path
Workbooks.Open (pt & "\IO Dialer Production Report-en-us.xlsx")
'ActiveWindow.Visible = False
For Each ws1 In ActiveWorkbook.Worksheets
If ActiveWorkbook.Worksheets(ws1.Name).Visible = True Then
ws1.Select
If ws1.Name Like "Work Group*" Or ws1.Name Like "Page Group*" Or ws1.Name Like "PC_GROUP*"
Then
ws1.Name = Range("A2").Value
Else
ws1.Name = Left(ws1.Name, Len(ws1.Name))
End If
End If
Next ws1
ActiveWorkbook.Save
ActiveWorkbook.Close

Workbooks.Open (pt & "\HOST3 IO Dialer Production Report-en-us.xlsx")


'ActiveWindow.Visible = False
For Each ws1 In ActiveWorkbook.Worksheets
If ActiveWorkbook.Worksheets(ws1.Name).Visible = True Then
ws1.Select
If ws1.Name Like "Work Group*" Or ws1.Name Like "Page Group*" Or ws1.Name Like "PC_GROUP*"
Then
ws1.Name = Range("A2").Value
Else
ws1.Name = Left(ws1.Name, Len(ws1.Name))
End If
End If
Next ws1
ActiveWorkbook.Save
ActiveWorkbook.Close

Application.Quit
Application.ScreenUpdating = True
End Sub

SSRS Expressions
="SELECT RTTERM, RTCAMP, RTACT_NBR, RTPTYPE, RTCALLN, RTCALLD, RTCALLT, RTCCOD, RTSITE,
RTPROCC, LASTCALL, RTSCORE, RTLOCTIME,RTRPC, RTNONCNT FROM ADMIN.ODS_IS_CCRESULT_ALL "
& " WHERE RTACT_NBR in ("&
iif(Parameters!p_AccountNumber.Value="","''",Parameters!p_AccountNumber.Value)&") "
& iif(Parameters!p_RTCALLN.Value="",""," AND RTCALLN in (" & Parameters!p_RTCALLN.Value & ") ")
& " AND RTCALLD between '" & Parameters!p_From.Value & "' AND '" & Parameters!p_To.Value & "'"

&" Union"

&" SELECT RTTERM, RTCAMP, RTACT_NBR, RTPTYPE, RTCALLN, RTCALLD, RTCALLT, RTCCOD, RTSITE,
RTPROCC, LASTCALL, RTSCORE, RTLOCTIME,RTRPC, RTNONCNT FROM ADMIN.ODS_IS_CCRESULT "
& " WHERE RTACT_NBR in ("&
iif(Parameters!p_AccountNumber.Value="","''",Parameters!p_AccountNumber.Value)&") "
& iif(Parameters!p_RTCALLN.Value="",""," AND RTCALLN in (" & Parameters!p_RTCALLN.Value & ") ")
& " AND RTCALLD between '" & Parameters!p_From.Value & "' AND '" & Parameters!p_To.Value & "'"

& iif(Parameters!p_From.Value="",""," AND RTCALLD >= '" & Parameters!p_From.Value & "' AND
RTCALLD <='" & Parameters!p_To.Value & "'")

=====================from Friday to Current Day --Non Rush Reports==========================

=switch(
WEEKDAY(Today,1)=1, DATEADD(dateinterval.Day, -3, today),
WEEKDAY(Today,1)=2, DATEADD(dateinterval.Day, -4, today),
WEEKDAY(Today,1)=3, DATEADD(dateinterval.Day, -5, today),
WEEKDAY(Today,1)=4, DATEADD(dateinterval.Day, -6, today),
WEEKDAY(Today,1)=5, DATEADD(dateinterval.Day, -7, today),
WEEKDAY(Today,1)=6, DATEADD(dateinterval.Day, -1, today),
WEEKDAY(Today,1)=7, DATEADD(dateinterval.Day, -2, today))

========================Rush Date =================


switch(
WEEKDAY(Today,1)=1, DATEADD(dateinterval.Day, -5, today),
WEEKDAY(Today,1)=2, DATEADD(dateinterval.Day, -6, today),
WEEKDAY(Today,1)=3, DATEADD(dateinterval.Day, -7, today),
WEEKDAY(Today,1)=4, DATEADD(dateinterval.Day, -1, today),
WEEKDAY(Today,1)=5, DATEADD(dateinterval.Day, -2, today),
WEEKDAY(Today,1)=6, DATEADD(dateinterval.Day, -3, today),
WEEKDAY(Today,1)=7, DATEADD(dateinterval.Day, -4, today))

==================================Current Date =========================


today
==================================Multiple values in Report filter===============
=split("BANK OF AMERICA, N.A.;FIA CARD SERVICES, N.A.",";")
=split("850;856;887;901;913",";")

850,856,887,901,913

===============================Last of Month ==========================


=DATEADD( "d", -1, DATEADD( "m", 1, DATEADD("d", -DAY( Fields!Document_Date.Value ) + 1,
Fields!Document_Date.Value ) ) )

===============================First Of Month ==========================


= DATEADD( "d", -DAY( Fields!Document_Date.Value ) + 1, Fields!Document_Date.Value )

================================Row Visibility Filter


========================================

RowVisibility Expression

=IIF(Fields!Seller.Value="CAPITAL ONE" AND (Fields!Portfolio.Value="1811" OR


Fields!Portfolio.Value="1812" OR Fields!Portfolio.Value="1813" OR Fields!Portfolio.Value="1814" OR
Fields!Portfolio.Value="1828" OR Fields!Portfolio.Value="1829" OR Fields!Portfolio.Value="1830" OR
Fields!Portfolio.Value="1831" OR Fields!Portfolio.Value="1850" OR Fields!Portfolio.Value="1851" OR
Fields!Portfolio.Value="1863" OR Fields!Portfolio.Value="1864" OR Fields!Portfolio.Value="1882" OR
Fields!Portfolio.Value="1883" OR Fields!Portfolio.Value="2301" OR Fields!Portfolio.Value="2300" OR
Fields!Portfolio.Value="2258" OR Fields!Portfolio.Value="2257" OR Fields!Portfolio.Value="2318" OR
Fields!Portfolio.Value="2319" OR Fields!Portfolio.Value="2358" OR Fields!Portfolio.Value="2359" OR
Fields!Portfolio.Value="2496" OR Fields!Portfolio.Value="2374" OR Fields!Portfolio.Value="2375" OR
Fields!Portfolio.Value="2376" OR Fields!Portfolio.Value="2377" OR Fields!Portfolio.Value="2420" OR
Fields!Portfolio.Value="2421" OR Fields!Portfolio.Value="2429" OR Fields!Portfolio.Value="2430" OR
Fields!Portfolio.Value="2449" OR Fields!Portfolio.Value="2450" OR Fields!Portfolio.Value="2495" OR
Fields!Portfolio.Value="2449" OR Fields!Portfolio.Value="2450" OR Fields!Portfolio.Value="2495" OR
Fields!Portfolio.Value="2496" OR Fields!Portfolio.Value="2531" OR Fields!Portfolio.Value="2532" OR
Fields!Portfolio.Value="2565" OR Fields!Portfolio.Value="2566"),false,IIF(((Fields!Seller.Value="Equable
Ascent Financial" OR Fields!Seller.Value="LHR INC." OR Fields!Seller.Value="SQUARETWO FINANCIAL
CORP" OR Fields!Seller.Value="COLLECT AMERICA" OR Fields!Seller.Value="ATLANTIC CREDIT &
FINANCE")
AND (Fields!Original_Lender.Value="CAPITAL ONE BANK" OR Fields!Original_Lender.Value="CAPITAL
ONE" OR Fields!Original_Lender.Value="CAPITAL ONE BANK, N.A." OR
Fields!Original_Lender.Value="CAPITAL ONE BANK (USA), N.A." OR
Fields!Original_Lender.Value="CAPITAL ONE F.S.B" OR Fields!Original_Lender.Value="CAPITAL ONE
BANK (USA), NA" OR Fields!Original_Lender.Value="CAPITAL ONE, N.A.")),FALSE,TRUE))

=split("FIA Card Services N.A.;CAPITAL ONE",";")

BELOW IS QUERY extract that WAS IMPLTEMENTED IN ABOVE EXPRESSION

("D_PORTFOLIO_LT"."SELLER_NAME" in ('CAPITAL ONE')


and
"D_PORTFOLIO_LT"."PORTFOLIO" in ('1811', '1812', '1813', '1814', '1828', '1829', '1830', '1831', '1850',
'1851', '1863', '1864', '1882', '1883', '2301', '2300', '2258', '2257', '2318', '2319',
'2358', '2359', '2496', '2374', '2375', '2376', '2377', '2420', '2421', '2429', '2430', '2449', '2450', '2495',
'2449', '2450', '2495', '2496', '2531', '2532', '2565', '2566')

or
"D_PORTFOLIO_LT"."SELLER_NAME" in ('Equable Ascent Financial', 'LHR INC.', 'SQUARETWO FINANCIAL
CORP', 'COLLECT AMERICA', 'ATLANTIC CREDIT & FINANCE')

and "D_ACCOUNT_LT"."ORIGLNDR" in ('CAPITAL ONE BANK', 'CAPITAL ONE', 'CAPITAL ONE BANK, N.A.',
'CAPITAL ONE BANK (USA), N.A.', 'CAPITAL ONE F.S.B', 'CAPITAL ONE BANK (USA), NA', 'CAPITAL ONE,
N.A.')

------------------------lookup---------------------------------------------------
=Lookup(Fields!POPORT_.Value,Fields!Portfolio.Value,Fields!Portfolio.Value,"DataSet2")

-----------------------lookupset------------------------------------------------
=join(LookupSet(Fields!POPORT_.Value,Fields!Portfolio.Value,Fields!Original_Account.Value,"DataSet2")
,vbCrLf)

=========================================
=iif(Fields!Proactive_Request_Y_N.Value="Y", 1 , 0)

======================
=Switch (Fields!Seller.Value="Target Financial Services" OR Fields!Seller.Value="TARGET NB AND
TARGET RC" OR Fields!Seller.Value="TARGET NB AND TARGET RL" OR Fields!Seller.Value="TD Bank USA,
N.A." , "Target",
Fields!Seller.Value ="Associates/Citibank/AT&T" OR Fields!Seller.Value="Citibank", "Citibank",
Fields!Seller.Value ="Bank of America" OR Fields!Seller.Value ="FIA Card Services N.A." ,"Bank of
America",
Fields!Seller.Value ="Capital One" OR Fields!Seller.Value = "Capital One F.S.B" ,"Capital One",
Fields!Seller.Value ="Chase" OR Fields!Seller.Value ="CHASE BANK USA, N.A." OR Fields!Seller.Value
="Washington Mutual", "Chase",
Fields!Seller.Value ="GE Capital Corporation" OR Fields!Seller.Value ="GE Capital / Wards" ,"GE Capital
Corp",
Fields!Seller.Value ="Household (OR-NV)" OR Fields!Seller.Value ="HSBC Card Services (III)" OR
Fields!Seller.Value ="HSBC Bank" , "HSBC",
Fields!Seller.Value ="Household (VA)" OR Fields!Seller.Value ="HSBC Consumer Lending Usa" ,
"Household",
Fields!Seller.Value ="AGF funding" OR Fields!Seller.Value ="American GEN.FIN.SER. DE" OR
Fields!Seller.Value ="American GEN.FIN.SER. IN" OR Fields!Seller.Value ="American GEN.FIN.SER. WI"
,"American General",
Fields!Seller.Value ="Collect America" OR Fields!Seller.Value ="SquareTwo Financial Corp"
,"SquareTwo" )

=============================
=iif(Fields!Proactive_Request_Y_N.Value = "N" , 1, 0 )

==============================
=iif(Isnothing(Fields!Account.Value),0 ,1 )

===================TO Show all the values in the Parameter ===================


="Selected Channel(s): " + Join(Parameters!p_channel.Value,",")

=split("STMT;CHRGOFF;LASTPMT",";")

SQL to find columns in a table in Netezza

SELECT
tablename,
attname AS COL_NAME,
b.FORMAT_TYPE AS COL_TYPE,
attnum AS COL_NUM
FROM _v_table a
JOIN _v_relation_column b
ON a.objid = b.objid
WHERE a.tablename = 'DW_POOL_DIM'
AND a.schema = 'ADMIN'
ORDER BY attnum;
Query having Inline Join for Bespoke Custome Offer Report :
SELECT

ODS_MIS_TEAMALIGNMENT.MONTH_END_DATE

,ODS_MIS_TEAMALIGNMENT.COLLECTOR_CODE

,ODS_MIS_TEAMALIGNMENT.REAL_NAME

,ODS_MIS_TEAMALIGNMENT.ALIAS_NAME

,ODS_MIS_TEAMALIGNMENT.TEAM_NUMBER

,GM.URANAM GROUP_MANAGER

,ODS_MIS_TEAMALIGNMENT.DIVISION

,DM.URANAM DIVISION_MANAGER

FROM ODS.ADMIN.ODS_MIS_TEAMALIGNMENT

LEFT JOIN ODS.ADMIN.ODS_IS_RCUSER GM ON ODS_MIS_TEAMALIGNMENT.GROUP_MANAGER = GM.URCCOD

LEFT JOIN ODS.ADMIN.ODS_IS_RCUSER DM ON ODS_MIS_TEAMALIGNMENT.DIVISION_MANAGER = DM.URCCOD

WHERE ODS_MIS_TEAMALIGNMENT.MONTH_END_DATE = (Select


MAX(ODS_MIS_TEAMALIGNMENT.MONTH_END_DATE) from ODS.ADMIN.ODS_MIS_TEAMALIGNMENT)

-----------------------------------------------BRAVURA------------------------------------------------------------------------------------

Issue 1 : Error in using below data in one of the queries being used n JOIN MDX
Queries .
[BUD_Resource].[Year].[Year].[Fiscal_Year]||[BUD_Resource].[Month].[Month]
.[Month_MM]

While joining Two queries from Cube after bringing from Union . IF Relational
function is being used then it will through error .

Issue 2 : Calculated measure should be attached to one of the Measure


hierarchy to work properly.and values should be taken from self query without
reference to items.
Issue 3 : Complete Members were coming in report when using Attribute for
display in crosstab and code from hierarchy in Expression .
Reso : It was coming because in Query subject we have taken the Attribute
before the Level.

You might also like