Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Cognos how to use the prompt dates in queries

Posted on 2008-06-16
3
Medium Priority
?
1,253 Views
Last Modified: 2010-04-29
Hi

I have a report that uses date prompts to select data from contracts. (cognos8)

Basically you enter a start date and an end date and I have created queries that select data between those dates.

What I need to do though is count the number of emplyees on a contract for each month between the dates entered. for example if I enter the start prompt as 01/12/07 and the end prompt as 31/12/08 I want the count of employees from 01/12/07 to 31/12/07 and then the 01/01/08 to the 31/01/08 and then the same for Feb, March, April etc all the way to Dec 08 (end prompt date) and then add them all together at the end! Any ideas welcome!!
0
Comment
Question by:ac_davis2002
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
RWrigley earned 2000 total points
ID: 21794827
I'm assuming you're using a relational model.  I'd probably create a data item that uses the "extract" function to pull the "month" out of the date, and group by that.  I'd probably have another dataitem called "OnContract" that determines if an employe was on contract on a given date, and has a value of 0 or 1.  Then , we can simply use the automatic aggregation to figure out how many employee's were on contract in any given grouping.
0
 

Author Comment

by:ac_davis2002
ID: 21795004
I am using a relational model yes.

That sounds like what I need.

Are you able to send me any example of the "extract" function?

This is the select statement I can use to extract the infomation for just one month

Select CPCompanyid,NoEmployees as noemp from CTContracts where Fromdate  
<= '20080430' and  EndDate >= '20080401' and CTcontracts.LKContractTypeID in (0,8) Order by CPCompanyid,ctcontractid  

The bit I am struggling with is using this statement in conjunction with the start and end date prompts and moving the dates forward to meet the time scales I need.
0
 

Author Closing Comment

by:ac_davis2002
ID: 31467577
Cheers!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question