Constructing a View into time dependant data

1. I have a table with data like this:
PersonID
DateTime
Temperature
Pressure
2. I want to build a view into this table so that it shows up as follows:
PersonID    DateTime1            DateTime2             DateTime3         .....
1                Pressure1              Pressure2                Pressure3        ......
1                Temperature1        Temperature2          Tempearture3  .....
2                :
how would I do this?

Below query will work above SQL 2005,
--create table routineCheck(PersonID int, [datetime] datetime, Temperature int, Pressure int)
--insert into routineCheck values
--(1,'01/01/2014', 61, 55),
--(2,'02/01/2014', 60, 52),
--(1,'01/05/2014', 62, 53),
--(3,'01/08/2014', 60, 55),
--(1,'02/07/2014', 63, 54),
--(2,'01/12/2014', 63, 55)
declare @cols nvarchar(max)
declare @stmt nvarchar(max)
select @cols = isnull(@cols + ', ', '') + '[' + cast(T.[datetime] as varchar)+ ']' from (select distinct [datetime] from routineCheck) as T
print @cols
select @stmt = '
select *
from (select PersonID, [datetime], Temperature from routineCheck) as T
pivot
max(T.temperature)
for T.[datetime] in (' + @cols + ')
) as P '
select @stmt = @stmt + ' union all
select *
from (select PersonID, [datetime], Pressure from routineCheck) as T
pivot
max(T.pressure)
for T.[datetime] in (' + @cols + ')
) as P1 order by PersonID'
exec sp_executesql @stmt = @stmt
Regards, RSingh

Similar Messages

  • Restriction of Time-dependent data (Cost Center) according to a specific role

    Dear experts,
    Has some one of you implemented a functionality to restrict Time-dependent data (for example, Cost Center) edition, according to a specific role assigned to an End user?
    I imagine it is possible, but we should develop an User-exit in order to get this goal.
    Let your comments here if possible, so that I can argue with my End user. I will try to give you points if you help me with this query.
    Thanks & Kind Regards,
    Daniel.

    Hello All!
    We have talked to Authorizations specialist and he indicated a customizing transaction in FI-AA module called ANSICHT (IMG -> Financial Accounting -> Asset Accounting -> Preparing for Production Startup -> Authorization Management -> Process Asset Views). In this customizing, it is possible to edit an existing asset view and turn on/off fields according to the company needs.
    Afterwards, you should request some adjustment in the roles that contain the A_A_VIEW authorization object.
    I am considering this question as "assumed answered'.
    Regards,
    Daniel

  • Time dependent data load to BW using Fixed Time Interval selection

    Hi,
    I'm facing a problem in extracting time-dependent master data to BW. I would really appreciate if anyone can help in this regard.
    We have a table in R/3 which has time-dependent data. For example, for a single OBJID we could have multiple records with different BEGDA/ENDDA and different attributes. When we try to load this data into BW InfoObject, we see a time-dependent data selection in update tab of infopackage. We need to select BEGDA/ENDDA in datasource since otherwise during loads we would get a "DUPLICATE RECORDS" load error in BW.
    The problem is when we enter a Fixed-time interval Start Data and End Date in the InfoPackage, only the records with that StartDate and EndDate are loaded. Ideally I would want to see all the records whose BEGDA/ENDDA falls in the range of StartDate and EndDate.
    I tried modifying the ROOSFIELD table for the data source. I made the BEGDA SELOPTS as GE(16) and ENNDA SELOPTS as LE(64). But still it doesn't seem to work. I checked if the change to ROOSFIELD has any affect in RSA3. Unless we give a range for BEGDA it doesn't seem to behave as expected. Could someone let me know how I can load all records to BW whose BEGDA/ENDDA fall in the range of StarteDate and EndDate.
    Thanks,
    Anil.

    Anil,
    If you are using a custom dataSource, make sure the dataSource fields for begda and ennda are labeled "datefrom" and "dateto".
    Cheers,
    T-

  • Extraction into Time dependent info object

    Dear all,
    In r/3 the field is time independent and want to extract the data into time dependent infoobject in bw.
    what is the procedure to do it.
    Regards,
    BPNR.

    Hi BPNR,
    You have two options:
    1. Make the info-object time independent and pull the data from R/3.
    2. Hard code the Date to and Date from fields in the infopackage to extreme values say 01/01/1900 to 31/12/9999 and extract the data from R/3.
    Hope this helps.

  • Time-Dependent Data in InfoPackage

    Hi, Experts,
    I tried to load CO Master Data from R/3, I got some issues as follow:
    1. In the InfoPackage creating, what is the meaning of Time-Dependent Data, How can I know what are the properly value range I should entry.
    2. After I excuted the Infopackage, I got red color in Monitor, I checked the PSA, some of the data's status were green, some were red which the system said that the records time overlapped, but I couldn't verify this is true anymore. Could you please give me some idea?
    By the way , does any body have the documents associated with BW-SD including extraction, Business Content and query design. Thanks a lot

    Hi Ryan,
    Time-dependent data means data varies from time to time. For example one employee may work in US from Aug - Feb and in Canada from Mar - Jul. Then to maintain such data you have to declare them as time-dependent.
    Time-dependent data has date-from and date-to fields. In your case the date-from and date-to have multiple entries thats the reason for the error.
    Bye
    Dinesh

  • Infopackage time dependant data fixed time interval

    Hi,
    I have issue with infopackage. When I tried to load the master data attribute itu2019s not loading the changed data.When I checked the infopackage it has update tab and in this time dependant data section,it was marked as fixed time interval.The changed data in R/3 actually falls under the interval what was entered in the fixed time interval period.But it was not extracted.
    I found that if we enter the exact specific dates interval in the fixed time interval,it fetches data.But we canu2019t enter each dates interval for all changed data in R/3. It needs to fetch all the data.When I try to remove the fixed time interval,it is not allowing as it is mandatory field.
    Please suggest me how to fetch all the records for time dependant data.I tried other options like routine and variables.But it doesnu2019t work and it is fetching data only if we enter the exact dates interval.
    Regards,
    Ramana

    There is nothing to do with PL/SQL.
    You can refer below links:
    http://www.lc.leidenuniv.nl/awcourse/oracle/server.920/a96524/c12parti.htm
    http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10739/partiti.htm#i1006727

  • Change to cost center in time dependent data. Can I rerun depreciation YTD?

    I need to change the cost center in October (Period 10) Period 9 and prior are already closed.  I thought that since I put the Interval for the new cost center as 1/1/11 that it might do and adjustment in October reversing the depreciation posted for the old cost center and put the YTD depreciation in the new cost center, but it did not.  it only posted the current month depreciation to the new cost center.  Is there any way to do this?  Thank you very much.

    Hi.  Thanks for your reply.  I went into the ABAA screen, but I am afraid to process this transaction because I do not understand what is going to happen.  I cannot find any documentation that explains this.  I have already changed the cost center on the asset and run depreciation.  It posted the current month depreciation to the new cost center, but it did not make a correction to the prior periods.  I am not creating a new asset, i just want to reclass the prior months depreciation (in the current year) to the new cost center.  In case it will help I provide some details:
    Asset acquired 5/1/11 Depreciation posted to Cost Center A From May - Sept $1,796.06 per month x 5 = $8,980.30
    Before posting Oct depreciation, I went to Master Data - Time Dependent - and changed the cost center as of 1/1/11. So I now have two intervals: From 1/1/1900-Cost Center A, and From 1/1/11 - Cost Center B. I then ran the regular depreciation for Oct. It posted Oct Depreciation of $1,796.06 to the new Cost Center-Cost Center B.  My total YTD depreciation is now $10,776.36, but it is split between two cost centers.  I need to move the depreciation from Cost Center A to Cost Center B for the prior months.  If it was a Journal Entry, I would do it as follows in the month of October, so my YTD numbers would be correct.
    Debit Depreciation Cost Center B   $8,980.30
    Credit Depreciation Cost Center A $8,980.30
    Then when I run my October numbers it would show zero depreciation in Cost Center A Year To Date (and negative 8,980.30 in month of October)
    If i follow the steps you propose, what would be the result?  Thanks so much!

  • Need to understand HR Time-dependent data

    Hi All,
    I am trying to understand how time-dependent master data works with fact table/infocubes. 
    Suppose I have a simple cube with infoObject: 0EMPLOYEE, 0HRPOSITION.  And the data are as follows:
    <u>0EMPLOYEE..............0HRPOSITION</u>
    300............................101
    Futhermore, my 0HRPOSITION master data is time dependent with an attribute of 0FUND and the master data are as follows:
    <u>START-DATE....END-DATE.....HRPOSITION...FUND</u>
    01/01/2006........05/15/2006....101..................A
    05/16/2006........12/31/9999....101..................B
    And if I were write a query against the cube to show the Employee #, the Position #, and the Fund, I would <b>expect</b> the query result as follows:
    300.....101....A
    300.....101....B
    However, my actual query result is only one row.  Why?
    Please any help will be much appreciated.
    Thanks,
    BQ

    BQ,
    Since it is timedependent master data, it will show only one record that active record.( because current system date will align with only one entry in 0HRPOSITION )
    RC

  • Master data records for time dependant data

    Hi
    In R/3. say master data has 1500 records. In BW, while loading this, i get the same number of records in monitor.
    But when i check the maintain master data for this info object, I find each row being duplicated. The difference being the valid to and valid from date. The info object is time dependant.
    So my question is: this adjustment done...is it ok continuing forward or do we change something now so that i dont see duplicate rows?
    Thanks in advance
    AR

    hi,
    everything is ok here (I assume you have timeframes for e.g.: 01.01.1000 - 27.12.2005 and 28.12.2005 - 31.12.9999).
    If you are working on developement system now - change something time-dependent in your master data tommorow (in your source system) and extract delta. Two new periods will be created and you will have 3 records, e.g.: 01.01.1000 - 27.12.2005 , 28.12.2005 - 28.12.2005 and 29.12.2005 - 31.12.9999.
    Regards,
    Andrzej

  • Getting latest record from time dependent data in DSO

    Hi folks,
    I have a standard DSO that is built on top off a time-dependent object.  Users don't need the daily history and the last entry of the month will suffice so we are only going to have 1 record per month at the most for the object. The standard dso object key thus contains the infoobject key and Calendar month which is derived from the 'From Date' of the infoobject.
    The users will running queries on this dso based on the Calendar month. So for the months, where record is available - it is a simple query. But get te data for the month where data is not available.
    Example:
    Key           Month
    123           Jan 2014
    123           Jun 2014
    So when the user runs the report for either of Feb/Mar/Apr/May 2014, the Jan 2014 record should show up.
    For anything June 2014 onwards, the Jun 2014 record should show up.
    Thanks for your suggestions!

    To month should be a part of data fields lets understand the behavior roughly with the above quoted example.
    Initial load to dso :
    123           Jan 2014        Dec 9999
    now change happens in master data new data record created with the to date fixed to 31.12.9999 and old record to date less than the from value of new record.Correct!
    Next load from master data to DSO.
    123           Jan 2014        May 2014
    123           Jun 2014        Dec 9999
    So what happened in this case that based on the employee and To month as key first record will get overwritten and new record will be appended as well.
    And rest you can handle at BEx level.
    Hope this works.
    Regards,
    AL

  • How to make Charc into time dependant

    Hi Gurus,
    i have a Characterstic like A which dont have any attributes but i want to make it time dependant when i right click and select change i don;t find any option...to make it timedependant...
    so i want to know is it possible if yes plz suggest me
    thanks in advance
    harish

    Hi harish
    Can u elaborate more ur question
    what whether matno is changing with time?
    Check these links also
    http://help.sap.com/saphelp_nw04/helpdata/en/80/1a634be07211d2acb80000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/13/c3e7379899d06fe10000009b38f8cf/content.htm
    may answer ur question
    regards
    NR

  • Moving time-dependant data from one table to another (archiving)

    Hello all
    I would like to know if there's an easier solution or a "best practice" to move data from one table to another. The context of this issue can be found within "archiving".
    More concretely: we have an application that uses several tables to log information to.
    These tables are growing like crazy, and we would like to keep only "relevant" data in those tables, so I was thinking about moving data from these tables that have been in there for, say 2 months, to "archiving" tables.
    I figured there must be some kind of "best practice" to get this done.
    I have already written a procedure that loops the table that has the time indicator and inserts the records from the normal tables into the archive tables (and afterwards delete this data), but it seems to be taking ages to get it done.
    Thanks in advance!
    Message was edited by:
    timschraepen

    There is nothing to do with PL/SQL.
    You can refer below links:
    http://www.lc.leidenuniv.nl/awcourse/oracle/server.920/a96524/c12parti.htm
    http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10739/partiti.htm#i1006727

  • Change of time dependent data

    Hi Experts,
    I have a cocode,for which BA financial statements are activated and also cross co code cost accounting is activated.
    we are using dep area 31 .
    for this company code time independent organisational units is activated.
    the issue:
    When i change the  Cost center in the master data,a new doc is created.but when i see in asset explorer and click on a transaction to see the doc  i found LC2 currency(2nd local currency) is not updating.
    other info:
    the two cost centers(old and new) were assigned the same co code.cost center currency is sa me as co code currency.
    exchange rates were maintained.when i see in the header data of teh doc i can see teh translation rate also.
    what could be the reasons for not updating the LC2 column.

    Hi,
    Is area 31 set up for the 2nd local currency?  We need to have a depreciation area set up for 2nd local currency.
    Thanks
    Muru

  • Changing the time dependent data

    Hi
    When I am trying to change the Cost center in the Asset Master, I am getting the following error:
    Fiscal year 2007 is already closed in Financial Accounting.
    Message no. AA669
    Diagnosis
    You have initiated a recalculation of asset values for fiscal year 2007. However, fiscal year 2007 is still open is Asset Accounting, but not in Financial Accounting.
    System response
    Due to this inconsistency between the General Ledger and the the subsidiary ledger, processing is terminated.
    Procedure
    Close fiscal year 2007 in Asset Accounting as well.
    I have executed the TC-AJRW & then AJAB. It worked properly in DEV client.When i did the same in prod. client it is giving the same error.
    Now what to do.
    Thanks
    shivaji

    Hi
    I have executed the TC-AJRW & then AJAB. It worked properly in DEV client.When i did the same in prod. client it is giving the same error for some asset & for some asset it is allowing to change.Why it is like this.
    Pl. advice.
    Thanks
    Shivaji

  • Time dependent communication data.

    Hi,
    I would like to create a time dependent communication data in the standard Business Partner transaction ( Tcode - BP ).
    Scenario : A customer might call in to inform that for the coming 2 months he'll be away and wants all the communications be sent to a differnet address for this two months.
    Standard SAP documentation says that the the Business Address Service which currently handles the address managemnt does not support time dependent data.
    http://help.sap.com/saphelp_470/helpdata/en/12/ad797a5c5811d3b4ea006094192fe3/frameset.htm
    Any workarounds to this problem? Anyone who has ever faced such a requirement? Appreciate any ideas on this.
    Thanks, Debasish

    Hi Debasish,
    Workarounds, 2 spring to mind both with pros and cons:
    1. Maintain the customer in another client (an exact copy of the customer), and then use ALE to time the change. This would allow you to store up to 1 time dependent change in the future.  So, when you knew a change was coming you could change the customer in the other client, and then schedule the ALE job to process the idoc on the date that the change was due to take place.  The pro of this work around is there is no development to do, the cons are that it means keeping your customer data in another client, and that you can only store one change into the future and its not so user friendly.
    2. Build your own time dependent function for communication data.  Build a dynpro which called the standard address handling screens and then store the data in the standard address tables linked to your own custom tables for date/time of change etc.  Then schedule a batch job every day (or hour, or as required) to look through your scheduled changes and then call a bapi or idoc or function to update the customer with the stored addresses.  This should be great from the user friendliness point of view and will allow any number of future changes of address for each customer, but will require some development effort (although not a huge amount as you will be using standard functions a lot).
    Hope that helps.
    Brad

Maybe you are looking for