Find intersections in date ranges and concatenate aggregated labels

Hello All,
The original source of data will be a table of persons with their member ship:
Description StartDate EndDate
18 Smith John Poker Club 01/01/2009 NULL
18 Smith John Library 05/01/2009 18/01/2009
18 Smith John Gym 10/01/2009 28/01/2009
26 Adams Jane Pilates 03/01/2009 16/02/2009
The challenge will be to find each intersection of membership date ranges for each person and produce for this each unique range:
a new line with the StartDate and EndDate of the range
Concatenate in the description the descriptions of the memberships for this range with:
“/” as separator
order by membership StartDate
This is the table of results expected:
18 Smith John Poker Club 01/01/2009 04/01/2009
18 Smith John Poker Club / Library 05/01/2009 09/01/2009
18 Smith John Poker Club / Library / Gym 10/01/2009 18/01/2009
18 Smith John Poker Club / Gym 19/01/2009 28/01/2009
18 Smith John Poker Club 29/01/2009 NULL
26 Adams Jane Pilates 03/01/2009 16/02/2009
Sample Script:
SET DATEFORMAT dmy
DECLARE @Membership TABLE (
PersonID int,
Surname nvarchar(16),
FirstName nvarchar(16),
Description nvarchar(16),
StartDate datetime,
EndDate datetime)
INSERT INTO @Membership VALUES (18, 'Smith', 'John',
'Poker Club', '01/01/2009', NULL)
INSERT INTO @Membership VALUES (18, 'Smith', 'John',
'Library', '05/01/2009', '18/01/2009')
INSERT INTO @Membership VALUES (18, 'Smith', 'John',
'Gym', '10/01/2009', '28/01/2009')
INSERT INTO @Membership VALUES (26, 'Adams', 'Jane',
'Pilates', '03/01/2009', '16/02/2009')
Note:Make sure that your solution uses a single query that starts either with "SELECT" or "WITH" or ";WITH".
Can you please share suggestions.
Regards,
Vaishu

This query
;WITH RS AS -- RangeStart
SELECT PersonID, StartDate AS RangeStart
FROM @Membership
UNION
SELECT PersonID, DATEADD(day, 1, EndDate) AS RangeStart
FROM @Membership
WHERE EndDate IS NOT NULL
RE AS -- RangeEnd
SELECT PersonID, DATEADD(day, -1, StartDate) AS RangeEnd
FROM @Membership
WHERE StartDate IS NOT NULL
UNION
SELECT PersonID, EndDate AS RangeEnd
FROM
@Membership
R AS -- Ranges
SELECT RS.PersonID, RS.RangeStart, RE.RangeEnd
FROM
RS CROSS APPLY
SELECT TOP (1) RE.RangeEnd
FROM RE
WHERE
RE.PersonID = RS.PersonID
AND (
RE.RangeEnd >= RS.RangeStart
OR RS.RangeStart IS NOT NULL AND RE.RangeEnd IS NULL
ORDER BY
ISNULL(RE.RangeEnd, '99991231')
) RE
SELECT R.*,
STUFF( (
SELECT '/' + m.Description
FROM
@Membership m
WHERE
m.PersonID = R.PersonID
AND (m.StartDate <= R.RangeEnd OR R.RangeEnd IS NULL) AND (m.EndDate >= R.RangeStart OR m.EndDate IS NULL)
FOR XML PATH('')
1, 1, '') AS Description
FROM
R
Returns this result:
PersonID
RangeStart
RangeEnd
Description
18
2009-01-01
2009-01-04
Poker Club
18
2009-01-05
2009-01-09
Poker Club/Library
18
2009-01-10
2009-01-18
Poker   Club/Library/Gym
18
2009-01-19
2009-01-28
Poker Club/Gym
18
2009-01-29
NULL
Poker Club
26
2009-01-03
2009-02-16
Pilates
EntityLite: A Lightweight, Database First, Micro ORM

Similar Messages

  • Mailbox Export - Filtered for Date Range and Body Content

    I have been pulling my hair out with this one and hopefully someone can help.
    I need to search a mailbox and export all (sent & received) messages that fit in a date range and also have a specific word in the body. The query I am using doesn't seem to find the term at all, but the messages it does find fit within my date range,
    so part of it seems to work. The request was to not use wildcards too, only looking for the specific word in the body. Here is my one-liner...
    New-MailboxExportRequest -ContentFilter {(Body -like "Something") -and (Received -gt "07/01/2012") -and (Received -lt "07/31/2012") -or (Sent -gt "07/01/2012") -and (Sent -lt "07/31/2012")} -Mailbox "SearchMailbox"
    -Name "Label1" -FilePath \\server\temp\pst\Export.pst
    I've also tried to search for a common word like "the" just to make sure it wasn't a case of the term simply not being in mailbox. No dice.

    Hi,
    Agree with Nickeyclayton, you can use (body -like "*something*") instead of (body -like "something").
    I recommend you refer to the following article:
    Filterable Properties for the -ContentFilter Parameter
    Property
    Description
    Values
    Example syntax
    Body
    This   property returns messages that have the specified string within the message   body.
    String
    Wildcard
    -ContentFilter {Body -like   "*prospectus*"}
    Hope this helps!
    Thanks.
    Niko Cheng
    TechNet Community Support

  • Need JavaScript for Sharepoint Designer 2010, to show a Pop-up to all the users between date range and the redirect the site

    Dear all,
    I am very new to Sharepoint designer 2010. Its better to say, i am just stepping in.
    I have sharepoint site which is accessible for all the users to update few information. But i want this site not to be accessible during a date range, say from 15th to 20th of every month.
    I am planning to have something like this: If any user tries to access this sharepoint site between 15th to 20th date range of everymonth, then the browser must show an pop-up alert saying "This site is not accessible during this date range" and Redirect
    this sharepoint site to someother site (Say http:// somesitename.xx.com) immidiately.
    I know very little about how to add Javascript in sharepoint webpart.
    Please provide the Javascript or any best alternate solution to my concern.
    Thanks in advance.

    Hi,
    From your description, my understanding is that you want to redirect sharepoint site to another site between 15th and 20th every month.
    I agree with what Sudip says. If you still want to use JS code,You could try these steps
    below:
    Open your site with SharePoint Designer.
    Click Master Pages in left navigation.
    Find file v4.master, and backup it(it is very important).
    Right click your v4.master,
    choose "Edit File in Adavance Mode".
    Add the code below into the <head/> tag.
    <script src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script><script
    type="text/javascript">
    $(document).ready(function(){
    var today = new Date();  
    var day = today.getDate(); // get current day
    var id = _spPageContextInfo.userid; // get the id of current logon in user
    var boolFlg = false;
    $.ajax({
       url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/SiteGroups/GetByName(\'"+"sharepoint Owners"+"\')/Users", //get users in a specified group can access the sharepoint site from 15th to 20th every
    month
       type: "GET",
       headers: {"accept": "application/json;odata=verbose"},
       success: function (data) {
          if (data.d.results) { 
             var src = data.d.results;
             for(var i = 0; i < src.length; i++){
                if(src[i].userid==id){ //check the logon in user in  the specified group or not
                   boolFlg = false;
                   break;
             if(!boolFlg){
                if(day <= 20 && day >=15){
                    alert("This site is not accessible during this date range"); // alert the message
                    location.href = "http:// somesitename.xx.com"; // redirect to another site
       error: function (xhr) {
          alert(xhr.status + ': ' + xhr.statusText);
    })</script>
    Best Regards
    Vincent Han
    TechNet Community Support

  • Moving multiple files by date range and/or file name filtered

    I need to move multiple files by date range and/or by filename (using a filter) to another directory. 
    OR
    How can I get the attributes of files in a directory, something you would see when typing in "dir" in a DOS or ls in UNIX.  I can parse this info and then make a array of files to move.
    The reason for needing this is that I need to move files that are located in another country, and sort them into different directories based on date.  Having to read each file for it's file information adds wasted time that I can't afford.  I am about to create a dos terminal to do a "dir" command to get the information and parse it out.. but I was hoping LV had a function that can get me that info so I don't have build it.
    THanks.

    You should use the 'File/Directory Info' functionality.
    This will return the last modificatoin of the file.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Find totals of a date range and sum

    How do I find totals between a date range like from 0 up to 60 days from today, 61 to 90 days from today, 91-120 days, 120 and above. Please advise.
    Do I use a Add_Months function to convert to days?

    Try this,
    This may help you
    SQL> select sysdate,sysdate+interval '60' day from dual;
    SYSDATE     SYSDATE+INTERVAL'60'DAY
    5/5/2008 2: 7/4/2008 2:17:16 PM
    SQL>G.

  • Support date range and as of date in Universe

    Hi,
    I have some questions on Universe design best practices. Can you please help ?
    We are using BO4 SP7 and UDT for universe design.
    Little bit on our schema: snow flake schema with multiple fact tables. Most of our table are 'Pure Type 6' dimension tables in which start date and end date are used to track historical data.  We also have date dimension table. We want to support both 'As of date' and custom 'date range' type reporting.
    Out typical use cases are like
    1. All items As of date
    2. All items between dates etc.
    How can we model it in the Universe ?
    1. We can not join every dimension with date_d dimension. So we have decided to put default conditions at Folder level. Our typical date conditions as below.
    date_d.end_full_date_utc  between  diminetion1_d.start_date AND diminetion1_d.end_date
    But problem is, table condition are not always applied. If we have A, B and C folders and if I create report by using objects from A and C then non of the condition applied to B appears in the query. This is problem for us.
    2. Other approach we thought is to define start and end prompt and define a restriction condition  for each and every table.
          diminetion1_d.start_date > [start_date_prompt] AND diminetion1_d.end_date < [end_date_prompt]
    We thought it will be too munch work as we have more than 150 tables and also 2 prompts will always appear, even of as of date, which may not look good.
    3. Is there a way apply to apply these date conditions at the individual table level so that they will appear in Query when ever the table is involved in the join path ?
    3. What is the best way to handle this kind of requirements, please suggest ?
    Thanks

    Hi,
    I have some questions on Universe design best practices. Can you please help ?
    We are using BO4 SP7 and UDT for universe design.
    Little bit on our schema: snow flake schema with multiple fact tables. Most of our table are 'Pure Type 6' dimension tables in which start date and end date are used to track historical data.  We also have date dimension table. We want to support both 'As of date' and custom 'date range' type reporting.
    Out typical use cases are like
    1. All items As of date
    2. All items between dates etc.
    How can we model it in the Universe ?
    1. We can not join every dimension with date_d dimension. So we have decided to put default conditions at Folder level. Our typical date conditions as below.
    date_d.end_full_date_utc  between  diminetion1_d.start_date AND diminetion1_d.end_date
    But problem is, table condition are not always applied. If we have A, B and C folders and if I create report by using objects from A and C then non of the condition applied to B appears in the query. This is problem for us.
    2. Other approach we thought is to define start and end prompt and define a restriction condition  for each and every table.
          diminetion1_d.start_date > [start_date_prompt] AND diminetion1_d.end_date < [end_date_prompt]
    We thought it will be too munch work as we have more than 150 tables and also 2 prompts will always appear, even of as of date, which may not look good.
    3. Is there a way apply to apply these date conditions at the individual table level so that they will appear in Query when ever the table is involved in the join path ?
    3. What is the best way to handle this kind of requirements, please suggest ?
    Thanks

  • Date Range and Format

    Post Author: cht104
    CA Forum: Formula
    I'm new to Crystal Reports so please bear with me.  I know this is easy and I'm just overlooking something obvious.  I've got my report formatted and working except for the getting the date range or prompt to work and the format of the date itself.  In my db, I"ve got a business_date field.  I've got that showing line by line in the report as yyyymmdd, but would like to be formatted as "Sept 11, 2007" if possible.  Also, for the date range, do I create a new formula or a new parameter field?  How exactly is that written out?  What other fields do I need to make this work?
    Thanks

    Post Author: cht104
    CA Forum: Formula
    {svc_at_dtl.svan} in &#91;"6036281297496447218", "6036281364474453041", "6036281475774461110", "6036282939574448316", "6036283115974448365", "6036283168796454200", "6036283395374462621", "6036283428674464130", "6036283753674445017", "6036283917774448418", "6036284153974449933", "6036284173996439566", "6036284257574445663", "6036284361474459493", "6036284371896470723", "6036284564874451909", "6036284758774459807", "6036284826974450872", "6036285282174468325", "6036285293874448033", "6036285529874453024", "6036285878174449855", "6036285999874448376", "6036286146296452491", "6036286186574458053", "6036286295596460760", "6036286335874446410", "6036286646674450703", "6036286674874445497", "6036286684874459826", "6036286879696436611", "6036286931974449860", "6036287191974445657", "6036287211774459063", "6036287254874446061", "6036287383874459108", "6036287395174475302", "6036287623696439776", "6036287911274449966", "6036287957774450009", "6036287972296473818", "6036289199196440994", "6036289336796478839", "6036289461796466359", "6036289792974471912", "6036289991196439695", "6275291111939468538", "6275291157455722999", "6275291342555724487", "6275291349939479559", "6275291437655724303", "6275291762455755275", "6275291867155724609", "6275291881655723946", "6275291886155724011", "6275292136155723957", "6275292195855724215", "6275292343855800229", "6275292363155724577", "6275292365155724637", "6275292431555731180", "6275292566755724381", "6275292632355723225", "6275292782455724172", "6275292851255723933", "6275292878655723921", "6275292953555723341", "6275293164155723919", "6275293169955723998", "6275293186455724649", "6275293318855723908", "6275293356655724478", "6275293373655724684", "6275293393739479064", "6275293553155724455", "6275293563655724004", "6275293586555778116", "6275293685955724201", "6275293757339475631", "6275293831955724141", "6275293834955730584", "6275293839562464447", "6275293884455723803", "6275293891639475878", "6275294142955724627", "6275294225939469203", "6275294244755724273", "6275294288755724162", "6275294326839466482", "6275294372355724667", "6275294446455724442", "6275294544655723239", "6275294595362458066", "6275294789855747474", "6275294965255727665", "6275295235155724432", "6275295284562503051", "6275295464555724584", "6275295543955724533", "6275295627755723584", "6275295787355723841", "6275295794955723386", "6275295812555723983", "6275295843555791857", "6275295862755722759", "6275295886755724259", "6275295914155723433", "6275295926255723304", "6275296134855724618", "6275296221455724401", "6275296317755723398", "6275296367355723312", "6275296369339471746", "6275296395339476301", "6275296663855724390", "6275296685255723246", "6275296714755724469", "6275296726455767720", "6275296746555724281", "6275296765355724086", "6275296772362502797", "6275296786862497240", "6275296997255724379", "6275297253355723475", "6275297266655724182", "6275297333955724555", "6275297497155723555", "6275297524455723179", "6275297573255724675", "6275297577455724220", "6275297741455812692", "6275297792755724410", "6275297869455724110", "6275297869455724110", "6275297899755723655", "6275297937155723570", "6275298123755730444", "6275298141555724499", "6275298269755791964", "6275298321455723972", "6275298361655724339", "6275298483355724658", "6275298658455722739", "6275298713155724108", "6275298747639512868", "6275298786555723464", "6275298854355724511", "6275298949755724320", "6275298993755724244", "6275299172655724547", "6275299224655724095", "6275299261439479425", "6275299271562505976", "6275299287155767711", "6275299417555724234", "6275299445555724363", "6275299463755727679", "6275299497755724052", "6275299561855724508", "6275299721255723338", "6275299743555724319", "6275299745855724293", "6275299755255769069", "6275299792555723668"&#93;anddate(tonumber({svc_at_dtl.business_date}&#91;1 to 4&#93;), tonumber({svc_at_dtl.business_date}&#91;5 to 6&#93;), tonumber({svc_at_dtl.business_date}&#91;7 to 8&#93;)) in {?date_range}
    I dont' know if my problem is with the "and", running 2 different things in here or just the date prompt.  Without the date prompt, I get my number information correctly

  • SUMIFS with Date Range and Condition

    Hi, I have search in the forums and read the online numbers guide but can't seem to get the formular working in Numbers.
    I want to sum up a column of durations, if they are in between 2 dates and meet the condition to belong to one project. I have the following table:
    project
    total duration
    project
    start
    end
    duration
    date range start
    date range end
    one
    0
    one
    02.01.2013
    02.01.2013
    15:30
    01.01.2013
    31.01.2013
    two
    0
    one
    03.01.2013
    03.01.2013
    15:30
    three
    two
    04.01.2013
    04.01.2013
    15:30
    four
    two
    05.01.2013
    05.01.2013
    15:30
    five
    three
    06.01.2013
    06.01.2013
    15:30
    six
    three
    07.01.2013
    07.01.2013
    15:30
    seven
    three
    08.01.2013
    08.01.2013
    15:30
    I have the following formular but it does not give me any value: =SUMIFS(F,C,A5,D"≥"$G$2,E"≤"$H$2)
    What am I doing wrong
    Thank you for your help.

    Hi Barry,
    thank you very much for your detailed reply.
    The first difference I spot is that my duration is in hours:minutes 00:00 but this should not make a difference, right? I attach you here some sample data:
    Project
    Start date
    Start time
    End date
    End time
    Duration
    Project 1
    07.01.2013
    11:00
    07.01.2013
    11:42
    00:42
    PINC: 1
    07.01.2013
    16:11
    07.01.2013
    17:11
    01:00
    Theatro
    07.01.2013
    19:50
    07.01.2013
    19:54
    00:03
    Project 3
    08.01.2013
    11:19
    08.01.2013
    13:30
    02:11
    Project 1
    09.01.2013
    12:32
    09.01.2013
    13:02
    00:30
    PINC: 1
    09.01.2013
    17:55
    09.01.2013
    18:29
    00:34
    Project 3
    09.01.2013
    18:29
    09.01.2013
    19:36
    01:06
    And I will go through my formular again and check if everything is correct.
    Many greets, Andreas

  • Restrict Query Data based on Date range and Users

    Hi All,
    I have a few web reports that I need do restrict data based on Users.
    In all the queries i have an infoobject 0CALDAY, and  a User Entry range variable on it. Because of performance issues  I need to restrict the range of dates a User can see. Typically most of users could go to a max date range of 1 month back. But some others would need the ability to see data for much bigger range of dates.
    Pls suggest how should i go about with this. Should I have to enforce this at Variable level(user exit).... but then i might have to maintain a table for the users.. Is there any other way of doing it.
    thanks
    Raj

    Any thoughts ?

  • Difficulty working with overlapping date ranges and sums

    I have data like the following and need help querying it for a specific result:
    startdate             enddate               place     class       number
    03-30-2006          04-18-2006          A             22           2000
    04-01-2006          04-30-2006          A             22           6000
    03-30-2006          04-15-2006          B             11           1700
    03-15-2006          04-12-2006          B             11           2900
    I'd like to return the sum of the averages for any given day, by place, and by class, like this:
    day                    place     class       average
    03-15-2006          B             11           100
    03-16-2006          B             11           100
    03-30-2006          A             22           100
    03-30-2006          B             11           200
    03-31-2006          A             22           100
    03-31-2006          B             11           200
    04-1-2006            A             22           300
    04-01-2006          B             11           200
    04-30-2006          A             11           200
    I'm stuck, any help would be GREATLY appreciated.

    307b218a-cebe-46f1-87b6-946b4076ce79 wrote:
    Here is what I said in my original post:
    I'd like to return the sum of the averages for any given day, by place, and by class.....Then gave an example of output.
    I think that sentence describes the relations perfectly succinctly.
    How can it, when there's no SUM involved
    307b218a-cebe-46f1-87b6-946b4076ce79 wrote:
    For the date of 3-30-2006, the sum of the averages for region A in class 22 is 100, since from 3-30-2006 to 4-18-2006 is 20 days, and 2000/20 = 100, and there are no other class 22's in place A in that date range. Same goes for 3-31-20006.
    However for 4-1-2006 the sum of the averages is 300, since I have one record who's average is 100 (2000/20), and another (6000/30 = 200) and 200 + 100 = 300.
    For 4/30, I have one average in that range for place A class 22, and its average for that period is 200.
    Does that help?
    Much better, thank-you ..
    try this:
    WITH data AS (
          SELECT TO_DATE('03-30-2006','mm-dd-yyyy') startdate, TO_DATE('04-18-2006','mm-dd-yyyy') enddate, 'A' place, 22 class, 2000 cnumber FROM DUAL UNION ALL
          SELECT TO_DATE('04-01-2006','mm-dd-yyyy') startdate, TO_DATE('04-30-2006','mm-dd-yyyy') enddate, 'A' place, 22 class, 6000 cnumber FROM DUAL UNION ALL
          SELECT TO_DATE('03-30-2006','mm-dd-yyyy') startdate, TO_DATE('04-15-2006','mm-dd-yyyy') enddate, 'B' place, 11 class, 1700 cnumber FROM DUAL UNION ALL
          SELECT TO_DATE('03-15-2006','mm-dd-yyyy') startdate, TO_DATE('04-12-2006','mm-dd-yyyy') enddate, 'B' place, 11 class, 2900 cnumber FROM DUAL ),
       data2 AS ( SELECT startdate, enddate, enddate-startdate+1 numdays, place, class, cnumber
                   FROM data d
    SELECT startdate+x.lvl day, place, class, cnumber/numdays avg
      FROM data2 d,
          ( SELECT level lvl FROM dual CONNECT BY level <= 10000 ) x
    WHERE x.lvl <= numdays
    ORDER BY d.startdate, x.lvl
    It helps to be specific and detailed

  • Defining Date range and using the same range to search the documents.

    Hi Sap Gurus,
    in our business there are some documents which do have Validity period, like say Inspection certificates and valid for say 10 months, ex..  JAN 25th 2009 to Oct 24th 2009
    we store this certificate in DMS and link to some SAP object say an Asset,
    we have a requirement to list all the documents based on the expiry date range. say to get a list of documents which are about to expire in 15 days, or the list of documents which have already expired
    I tried to define a characteristic in date format, but it is a single value field, and search is only supported on that specific value only.
    like we cannot serch the DIR falling in between this Date Ranges.
    also report of Documents which are to expire in 15 days could not be got.
    is there a way to meet this requirement , if it is through a development also please tell me how the logic could be built
    Thanks and regards
    Priya S

    Hi SAP Gurus,
    Thanks much Thomas for your Promt reply.
    The solution provided by Thomas really works but the same thing is not possible in EDMS,
    in Easy DMS we cannot manually give any value in the date characteristics field, the system will ask to fill from the date window format.
    so we cannot enter < or > <> value in characteristics, hope there is any note or other procedure to get the same funtionality.
    please if any one worked on the same with EDMS  let me know
    Thanks and kind regards
    Priya S

  • Need MDX query to find something like date diff and Date Range for last 10 days

    Hi ,
    I need two Query .First Query for below;
    I have below data in table like.
    Cat      StartDate    EndDate     
    A    2000-01-01     2000-01-15   
    B    2000-01-02     2000-01-30    
    C    2000-01-01     2000-01-31    
    D    2000-02-01     2000-02-28    
    A    2000-01-10     2000-01-31    
    I need if Startdate and Date completes whole one month then set status =1 else  0 using MDX query.
    like this ;
    Cat      StartDate    EndDate       Status
    A    2000-01-01     2000-01-15    1
    B    2000-01-02     2000-01-30    0
    C    2000-01-01     2000-01-31    1
    D    2000-02-01     2000-02-28    1
    A    2000-01-10     2000-01-31    1
    In second query I need last 10 days from current days like;
    Now = 8/20/2014
    output will be ;
    8/20/2014
    8/19/2014
    8/18/2014
    8/17/2014
    8/16/2014
    8/15/2014
    8/14/2014
    8/13/2014
    8/12/2014
    8/11/2014
    8/10/2014
    Please help me .
    Thanks

    Hi Prajapati,
    In your scenario, you can use Properties and Datediff function to achieve your requirement. Since not know the structure of your cube, we cannot give you the esact query.
     I have tested it on the AdventureWorks cube, the query below is for you reference.
    WITH MEMBER [Measures].[StartDate]
    AS
    [Employee].[Employee Department].CURRENTMEMBER.PROPERTIES('Start Date')
    MEMBER [Measures].[WorkYear]
    AS
    DATEDIFF('yyyy',[Measures].[StartDate],NOW())
    MEMBER [Measures].[Status]
    AS
    IIF(DATEDIFF('yyyy',[Measures].[StartDate],NOW())>10,1,0)
    SELECT {[Measures].[StartDate],[Measures].[WorkYear],[Measures].[Status]} ON 0,
    [Employee].[Employee Department].[Employee].MEMBERS ON 1
    FROM [Adventure Works]
    Results
    Reference
    http://msdn.microsoft.com/en-us/library/ms144821.aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • Generate a report with date range and year as POV with Hyp Planning ?

    Hi everybody,
    I am starting with hyp planning and i need your help please.
    I have to create some forms. In those forms, the final user is supposed to be able to display data in the forms between 2 dates and for a specific year.
    My first problem : I don't know how you can display data in a form between 2 dates and for one specific year. I just have one dimension YEAR and one PERIOD, so if i selected them as a PAGE, the final user will just be able to choose the month and the year for his form ... and not displaying data between 2 dates.
    My second problem is with the dimensions YEAR, SCENARIO and VERSION. I don't want to put the dimensions VERSION and SCENARIO as PAGE (it easier for the final user to just choose a year than to choose a year, scenario, and version) but as POV with a relationship with the dimension YEAR (because if the user chooses YEAR = actual_year (2012) the VERSION and the SCENARIO won't be the same than if the user chooses YEAR= last_year). IF YEAR = next_year, VERSION=Propuesta, SCENARIO=Forecast
    IF YEAR = actual_year, VERSION=Propuesta, SCENARIO=Forecast AC
    IF YEAR = last_year, VERSION=Actual, SCENARIA=Real
    How can i do that?
    Thank you for your help
    Edited by: 932573 on May 7, 2012 3:44 PM
    Edited by: 932573 on May 7, 2012 4:27 PM

    I am not sure if you are using RAS or Enterprise SDK, but here are some code snippets to set range report parameters:
    For scheduling:
    // oReport is IReport object holding the crystal report.
    oReportParameter = oReport.getReportParameters().get(i);
    currentRangeValue = oReportParameter.getCurrentValues().addRangeValue();
    currentRangeValue.getFromValue().setValue(dateParameter);
    currentRangeValue.getToValue().setValue(dateParameter);
    For viewing:
    ParameterFieldRangeValue pfrv = new ParameterFieldRangeValue();
    pfrv.setBeginValue(dateTimeValue);
    pfrv.setEndValue(dateTimeValue1);
    pfrv.setLowerBoundType(RangeValueBoundType.inclusive);
    pfrv.setUpperBoundType(RangeValueBoundType.inclusive);
    pf.getCurrentValues().add(pfrv);
    f.add(pf);
    f is Fields object and pass that to viewer.

  • Using criteria on date ranges and ignoring times, best method

    Where col.date is a date and time datatype, I know that by using:
    trunc(col.date) between trunc(sysdate-10) and trunc(sysdate)
    or
    to_char(col.dat,'YYYYMMDD') between to_char(sysdate-10,'YYYYMMDD') and to_char(sysdate,'YYYYMMDD')
    the results will include rows where col.date is between and including sysdate less 10 days and sysdate.
    However, this means Oracle will not use any ordinary (ie not function based) index on the table.
    I do not want to add another index (it's a transaction table with many transactions per second) and I would like to improve the speed of the query.
    I know that it is close to use
    col.date between sysdate-10 and sysdate+ (1-1/(60*60*24)) but this will cause missed data.
    select sysdate-10 from dual
    2007-01-20-14.03.44
    But I want to include any transaction on 2007-01-20, before, during and after the time of 14.03.44.
    Perhaps I have to either live with the speed problem or create a function based index on trunc(col.dated).
    Any comments, thanks?

    If you worry about index using why not to use <<datecolumn>> >= trunc(sysdate-10) and <<datecolumn>> < trunc(sysdate+1) ?
    SQL> create table t (dt) as select sysdate+10-rownum from dict where rownum <=30;
    Table created.
    SQL> alter table t add primary key (dt);
    Table altered.
    SQL> set autotrace on
    SQL> select dt from t where trunc(dt) between trunc(sysdate-10) and trunc(sysdate);
    DT
    20-JAN-07
    21-JAN-07
    22-JAN-07
    23-JAN-07
    24-JAN-07
    25-JAN-07
    26-JAN-07
    27-JAN-07
    28-JAN-07
    29-JAN-07
    30-JAN-07
    11 rows selected.
    Execution Plan
    Plan hash value: 209346666
    | Id  | Operation        | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |             |    11 |    99 |     1   (0)| 00:00:01 |
    |*  1 |  FILTER          |             |       |       |            |          |
    |*  2 |   INDEX FULL SCAN| SYS_C005970 |    11 |    99 |     1   (0)| 00:00:01 |
    SQL> select dt from t where dt >= trunc(sysdate-10) and dt < trunc(sysdate+1);
    DT
    20-JAN-07
    21-JAN-07
    22-JAN-07
    23-JAN-07
    24-JAN-07
    25-JAN-07
    26-JAN-07
    27-JAN-07
    28-JAN-07
    29-JAN-07
    30-JAN-07
    11 rows selected.
    Execution Plan
    Plan hash value: 114909756
    | Id  | Operation         | Name        | Rows  | Bytes | Cost (%CPU)| Time
    |
    |   0 | SELECT STATEMENT  |             |    11 |    99 |     1   (0)| 00:00:01
    |
    |*  1 |  FILTER           |             |       |       |            |
    |
    |*  2 |   INDEX RANGE SCAN| SYS_C005970 |    11 |    99 |     1   (0)| 00:00:01
    |
    --------------------------------------------------------------------------------Rgds.

  • How to find Where does Data Elements and structures are used ?

    Hi everyone .
    Is there any table which stores data elements/structures and where they are used ?
    If not is there any way to find by writing some <b>program</b> where does a data element or a structure is used ? Which tables will require for that ? If any one can give example it will be most helpful .
    Thanks and Regards,
    Kaushal N. Shah

    Hi Kaushal,
    DD04L stores the data elements.
    DD02L stores the structures.
    So you can query these tables & find them.
    Regards,
    Chetan.
    PS:Reward points if this helps.

Maybe you are looking for