Can select statement return 'No Record found' for each of invalid inputs.

Let say when you select a invalid booking number, oracle will
return nothing, but do u know how to make oracle return a record
saying it's invalid?
Example, the following sql normally return 3 records cause
only 3 numbers are valid, is there anyway to make it return
4 records and indicate those invalid ones are invalid somehow.
select booking_service, BOOKING_NO from tb_booking where booking_no in ('valid1','INVALID', 'valid2', 'valid3')

Along the same lines you could use object types to achieve the same result. This would remove the need for a temporary table, and also allow you to create the list of ids to check with PL/SQL without i/o. As an example
CREATE TYPE booking_id_typ IS OBJECT (id NUMBER);
CREATE TYPE booking_id_list_typ IS TABLE OF booking_id_typ;
CREATE TABLE bookings (booking_id booking_id_typ);
(you could have booking_id as type NUMBER, but for consistency with subsequent SQL I've used booking_id_typ)
INSERT INTO bookings VALUES (booking_id_typ(10));
INSERT INTO bookings VALUES (booking_id_typ(20));
INSERT INTO bookings VALUES (booking_id_typ(40));
INSERT INTO bookings VALUES (booking_id_typ(50));
The following SQL statement creates a collection on the fly, rather than using an IN clause.
SELECT i.id booking_id, DECODE(b.booking_id.id, NULL, 'Invalid', 'Ok') status
FROM bookings b,
SELECT id
FROM TABLE(booking_id_list_typ(booking_id_typ(10), booking_id_typ(20), booking_id_typ(30), booking_id_typ(40)))
) i
WHERE i.id = b.booking_id.id (+)
BOOKING_ID STATUS
10 Ok
20 Ok
30 Invalid
40 Ok
This SQL statement works in 9i. I get the following error in 8i, but you might be able to CAST the TABLE to booking_id_list_typ, or depending on your application, create a PL/SQL variable of type booking_id_list_typ and CAST that instead.
ERROR at line 5:
ORA-22905: cannot access rows from a non-nested table item

Similar Messages

  • Payment F110 - No data records found for these selection criteria, FZ208

    Hi all,
    I have done all configuration for payment medium for a customer in Norway. We use Telapay and program RFFONO_T. We have not activated the new general ledger but we have ECC 6.0 so I do not see why it should not work.
    The invoices got paid with payment order but when I should download the file in Environment > Payment medium > DME Administration I got the following error message:
    "No data records found for these selection criteria
    Message no. FZ208
    Diagnosis
    No data could be accessed for this selection.
    Possible causes are:
    No data exists for the activated selection.
    You have no authorization to display or edit data from this selection.
    Procedure
    First check whether your selection criteria are correct.  You may need to expand the criteria to include a larger search area to check whether data exists in the system.
    Make sure you have the proper authorizations for displaying and editing data.  Read the Release note for DME management for further information on the authorization objects.
    Proceed"
    I have tried with different variants but that doesn´t matter. When I look at the payment run log I can see following:
    "Additional parameter specifications 1400 SAPO02 are missing
    Message no. FR193
    Diagnosis
    Entry 1400 $V2& is missing from the additional company code parameter table.
    System Response
    Processing was terminated.
    Procedure
    Maintain the entry according to the instructions in the program documentation."
    I suppose that´s why I can´t get a file. Do any one of you know why I can´t get the file created. Please help.
    Best regards Lisa

    Hi Lisa,
    I have a similar problem with program RFFONO_T and Telepay format for a Norwegian customer. Payment medium is not created. In the payment run log is the following message: "Additional parameter specifications XXXX SAPO02 are missing
    Message no. FR193.Entry XXXX $V2& is missing from the additional company code parameter table."
    According the program documentation for RFFONO_T, a company number (11 digits) has to be maintained under company code global data, additional details. The legal org.number with 9 digits is already entered but I do not understand where to enter a 11 digits company number? A user number (10 digits) is also entered in trans OB94  but the problem remains.
    Did you find a solution to your problem?
    Regards,
    Agneta

  • Calendar and Adressbook error: Duplicate records found for GUID

    Hi all,
    i have a Mountaion Lion Server running on a mac mini and everything was working well.
    This morning one user of mine is unable to connect to his calendar and adressbook.... i found this error in the log files:
    2013-06-30 15:19:50+0200 [-] [caldav-1]  [-] [twistedcaldav.directory.appleopendirectory.OpenDirectoryService#error] Duplicate records found for GUID ****USER_GUID****:
    2013-06-30 15:19:50+0200 [-] [caldav-1]  [-] [twistedcaldav.directory.appleopendirectory.OpenDirectoryService#error] Duplicate: ***USER_Shortname***
    Apperetnly there is a duplicate match in the database. how can i fix this issue?
    In Server App this user is only listed once.
    Mail and other services for this user are working correctly.
    Thanks for any advice!

    Hi Samuel,
    You may try:
    select code,count(code)
    from [dbo\].[@XTSD_XA_CMD\]
    group by code having count(code) > 1
    What is the result?
    Thanks,
    Gordon

  • Sql query - Selecting last recorded values for each date in specified period

    Hello,
    Can someone please help me with my problem.
    I'm trying to get last recorded balance for each day for specific box (1 or 2) in specified period of days from ms access database using ADOTool.
    I'm trying to get that information with SQL query but so far unsuccessfully...  
    My table looks like this:
    Table name: TestTable
    Date Time Location Box Balance
    20.10.2014. 06:00:00 1 1 345
    20.10.2014. 12:00:00 1 1 7356
    20.10.2014. 18:45:00 1 1 5678
    20.10.2014. 23:54:00 1 1 9845
    20.10.2014. 06:00:02 1 2 35
    20.10.2014. 12:00:04 1 2 756
    20.10.2014. 18:45:06 1 2 578
    20.10.2014. 23:54:10 1 2 845
    21.10.2014. 06:00:00 1 1 34
    21.10.2014. 12:05:03 1 1 5789
    21.10.2014. 15:00:34 1 1 1237
    21.10.2014. 06:00:00 1 2 374
    21.10.2014. 12:05:03 1 2 54789
    21.10.2014. 15:00:34 1 2 13237
    22.10.2014. 06:00:00 1 1 8562
    22.10.2014. 10:00:00 1 1 1234
    22.10.2014. 17:03:45 1 1 3415
    22.10.2014. 22:00:00 1 1 6742
    22.10.2014. 06:00:05 1 2 562
    22.10.2014. 10:00:16 1 2 123
    22.10.2014. 17:03:50 1 2 415
    22.10.2014. 22:00:10 1 2 642
    23.10.2014. 06:00:00 1 1 9876
    23.10.2014. 09:13:00 1 1 223
    23.10.2014. 13:50:17 1 1 7768
    23.10.2014. 19:47:40 1 1 3456
    23.10.2014. 21:30:00 1 1 789
    23.10.2014. 23:57:12 1 1 25
    23.10.2014. 06:00:07 1 2 976
    23.10.2014. 09:13:45 1 2 223
    23.10.2014. 13:50:40 1 2 78
    23.10.2014. 19:47:55 1 2 346
    23.10.2014. 21:30:03 1 2 89
    23.10.2014. 23:57:18 1 2 25
    24.10.2014. 06:00:55 1 1 346
    24.10.2014. 12:30:22 1 1 8329
    24.10.2014. 23:50:19 1 1 2225
    24.10.2014. 06:01:00 1 2 3546
    24.10.2014. 12:30:26 1 2 89
    24.10.2014. 23:51:10 1 2 25
    Let's say the period is 21.10.2014. - 23.10.2014. and I want to get last recorded balance for box 1. for each day. The result should look like this:
    Date Time Location Box Balance
    21.10.2014. 15:00:34 1 1 1237
    22.10.2014. 22:00:00 1 1 6742
    23.10.2014. 23:57:12 1 1 25
    So far I've managed to write a query that gives me balance for ONLY ONE date (date with highest time in whole table), but I need balance for EVERY date in specific period.
    My incorrect code (didn't manage to implement "BETWEEN" for dates...):
    SELECT TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM TestTable
    WHERE Time=(SELECT MAX(Time)
    FROM TestTable
    WHERE Location=1 AND Box=1 );
    Tnx!
    Solved!
    Go to Solution.

    For loop
    following query keep day (here 24 in below query) Variable from ( 1 to 28-29/30/31 as per month)
    SELECT TOP 1 TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM Test Table.
    WHERE  Time=(SELECT MAX(Time) FROM TestTable WHERE Location=1 AND Box=1 )
    AND DATE = "2014-10-24";
    PBP (CLAD)
    Labview 6.1 - 2014
    KUDOS ARE WELCOMED.
    If your problem get solved then mark as solution.

  • Q-Info Record found for material rev level 06

    Dear All
    I have an error Q-info record found for material xxx rev level 06 while doing migo inbound delivery. Even i verify with some documents also but till not to come out of this problem. Is any body having solution.
    Please specify whether it is minor or major problem.
    Awaiting for ur reply

    In QI01/QI02--->You must have created the quality Info record for the vendor /material/revision combination.
    Suppose Material for which PO is cretaed is having latest revision 6 & infor record exists for rev 5 or less and not for rev level 6 ,then you may get this error.Also if relase date for vendor /material/revision combination is not valid then also you can get such error.
    only way is you can create with future relase date..and chaeck again.

  • Why can't I adjust the recording level for a Blue mic???

    Why can't I adjust the recording level for a Blue mic???

    Most Blue usb mics have a gain control somewhere on them.

  • Which table include duration&data records number for each nodes in PC?

    Hi Experts,
    Now I am on Process Chains maintenance work, I need daily record a very huge infopackage process chain's each nodes more then 50 infopackage, record something like duration ,data records nubmer for each infopackage. I need check this one by one in process chain, and my question is do you know this infomation record in which table in BW system? if i know it I will write a program to get it in one time.
    Thanks in advance!

    Hi,
    You can find the information about the process[as you said nodes]  in his tables ,
    RSPCPROCESSLOG - Stores complete information about the finished process
    RSPCPROCESSINSTANCE - Stores the meta data for the successor process..it also has the runtime
    RSPCVARIANT and RSPCVARIANTATTR - the succesor process reacts to the event
    Process chain related tables are start with RSPC*.
    under Settings ® Maintain Process Types (table RSPROCESSTYPES).
    Pls chk this link;
    http://help.sap.com/saphelp_nw04/helpdata/en/8f/c08b3baaa59649e10000000a11402f/frameset.htm
    Other tables used for Process chains:
    http://wiki.sdn.sap.com/wiki/display/BI/ProcessChainTables
    Thanks
    Hemav
    Edited by: hemav on Aug 4, 2010 7:38 AM

  • Can we have set PF status seperately for each list in in teractive reportin

    can we have set PF status seperately for each list in in teractive reportin

    yes.
    just check
    at user-command.
    sy-lsind = sy-lsind + 1.
    if sy-lsind = 1.
    set pf-status 'ZTEST'.
    elseif sy-lsind = 2.
    set pf-status 'ZTEST1'.
    end if.
    like that.
    regards
    shiba dutta

  • I have multiple songs I would like to include in my slideshow.  Can I change the rate of presentation for each song?  For instance, upbeat song with a 2 secong presenation time and slower song with a 3 second presentation time?

    I have multiple songs I would like to include in my slideshow.  Can I change the rate of presentation for each song?  For instance, upbeat song with a 2 secong presenation time and slower song with a 3 second presentation time

    Alternatives to iPhoto's slideshow include:
    PhotoToMovie  $49.95
    PulpMotion  $129
    FotoMagico $99
    Final Cut Pro X $299
    It's difficult to compare these apps. They have differences in capability - some are driven off templates. some aren't. Some have a wider variety of transitions. Others will have excellent audio controls. It's worth checking them out to see what meets your needs. However, there is no doubt that Final Cut Pro X is the most capable app of them all. You get what you pay for.

  • Select statement in a sub routine(For Sapscript)

    Hi,
    M unable to write select statement for my reqirement in Sap-script in Sub routine.
    My requirement is 1)"Your correspondent for quality" in main window of my form.
    For dis rule is as below
    "Get the 'changed by' value resord in table QCPR field AENDERER.For the same value found in tabe USR21 fiels BNAME,pick up the PERSUNUM value.For dis PERSUNUM value, found in ADRP feild NAME_TEXT the value for "Your Correspondent for Quality".
    2) For this PERSUNUM value found in ADCP-TEL_NUMBER the vakue for "Ph".
    3)For this PERSUNUM value found in ADCP-FAX_NUMBER the vakue for "FAX".
    4For this PERSUNUM value found in ADR6-SMTP_ADDR the vakue for "EMAIL".
    Please help me out it's urgent for me.I wil b waiting 4 ur reply.

    READ TABLE in_par WITH KEY 'QCPR-AENDERER'.
      CHECK sy-subrc = 0.
      MOVE in_par-value TO V_aenderer
    .  READ TABLE in_par WITH KEY 'USR21-BNAME.
      CHECK sy-subrc = 0.
      MOVE in_par-value TO V_bname
      SELECT SINGLE persnumber addrnumber
        INTO wa_usr21-persnumber wa_usr21-addrnumber
        FROM usr21
        WHERE bname = V_bname
    and <b>check field for this</b> = V_aenderer.
      CHECK sy-subrc = 0.
      SELECT SINGLE tel_number fax_number
        INTO adcp-tel_number adcp-fax_number
        FROM adcp
        WHERE addrnumber = usr21-addrnumber
          AND persnumber = usr21-persnumber.
      CHECK sy-subrc = 0.
      READ TABLE out_par WITH KEY 'ADCP-TEL_NUMBER'.
      CHECK sy-subrc = 0.
      out_par-value = adcp-tel_number.
      MODIFY out_par INDEX sy-tabix.
      READ TABLE out_par WITH KEY 'ADCP-FAX_NUMBER'.
      CHECK sy-subrc = 0.
      out_par-value = adcp-fax_number.
      MODIFY out_par INDEX sy-tabix.
      SELECT SINGLE smtp_addr
        INTO adr6-smtp_addr
        FROM adr6
        WHERE addrnumber = usr21-addrnumber
          AND persnumber = usr21-persnumber.
      READ TABLE out_par WITH KEY 'ADR6-SMTP_ADDR'.
      CHECK sy-subrc = 0.
      out_par-value = adr6-smtp_addr.
      MODIFY out_par INDEX sy-tabix.
    Regards

  • Can i make a sequence to create a record number for each new record

    Does anybody know if a field can be inserted to or a feature turned on to create a automatic numbering system for each incoming record

    It's easier if you don't. You can do what you want using a template, but it will require some scripting. It's also easier to do than describe, but I'll try. Begin by creating the fields on a page in the locations you want, insert this page to the document, as the first page for example. You can then replace it with a blank page, which will leave the form fields behind. Then make this page a template and hide it. You can then run a script from the interactive JavaScript console that spawns the hidden template on the first page as an overlay, extracts the page that now has fields as a new document, and repeat for the rest of the pages. Here are links to documentation of some of the scripting that will be involved:
    template.spawn: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1216.html
    doc.extractPages: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.465.html
    The process for making a page a template through Acrobat's UI depends on what version you're using, but it can be doen programmatically too: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.451.html

  • Last() not returning correct value within for-each-group

    I've found inconsistent results between JDeveloper and SOA Suite using the xslt 2.0 for-each-group construct.
    &lt;xsl:for-each-group select="Po/PoLine" group-by="itemId"&gt;
    &lt;xsl:if test="position()=1"&gt;
    &lt;GroupCount&gt;
    &lt;xsl:value-of select="last()"/&gt;
    &lt;/GroupCount&gt;
    &lt;/xsl:if&gt;
    &lt;/xsl:for-each-group&gt;
    What I expect is the function last() to give me the number of groups which is the unique number of itemIds.
    In JDeveloper 10.1.3.4, testing this construct gives me what I expect.
    At run-time (deployed to 10.1.3.3 SOA Suite), the value returned is the total number of records, not the number of groups.
    For example, given the following XML
    &lt;Po&gt;
    &lt;PoLine&gt;
    &lt;itemId&gt;<strong>001</strong>&lt;/itemId&gt;
    &lt;description&gt;Hammer&lt;/description&gt;
    &lt;quantity&gt;10&lt;/quantity&gt;
    &lt;/PoLine&gt;
    &lt;PoLine&gt;
    &lt;itemId&gt;<strong>001</strong>&lt;/itemId&gt;
    &lt;description&gt;Hammer&lt;/description&gt;
    &lt;quantity&gt;10&lt;/quantity&gt;
    &lt;/PoLine&gt;
    &lt;PoLine&gt;
    &lt;itemId&gt;<strong>002</strong>&lt;/itemId&gt;
    &lt;description&gt;Nail&lt;/description&gt;
    &lt;quantity&gt;10&lt;/quantity&gt;
    &lt;/PoLine&gt;
    &lt;/Po&gt;
    Grouping by <strong>itemId</strong>, last() should return 2 as there are two groups (001 and 002). JDeveloper does this.
    When deployed to SOA Suite, last() returns 3.
    Any ideas?

    Hi,
    if JDeveloper is doing the right thing then this issue should be reported to the SOA Suite forum or BPEL BPEL , what do you think ?
    Frank

  • Can I assign several physical storage locations for each virtual machine when using the replication-feature from Hyper-V 2012 R2?

    Hi everyone,
    I have 2x physical servers running Hyper-V 2012 R2. Each hosts several virtual machines. The VHDs of the VMs are stored on several dedicated physical disks to have a performance boost. For exampe if VM A has two VHDs attached I made sure that the VHDs are
    on different physical disks to have them not slow-down each other in case of intensive disk accesses.
    So far so good. I was looking forward to the replication-feature. The idea is to have the two physical servers have their primary running VMs being replicated to the other physical server and vice-versa. I was hoping to have the chance to choose for each
    individual VM where the replicated VHD will be stored. But instead I can only see the one location/path which is configured in Hyper-V Manager when I activate the replication-feature on the server.
    Is there by any chance a way how to select the storage location for each VHD/VM if using the replication-feature of Hyper-V 2012 R2?
    Thanks in advance.
    Cheers,
    Sebastian

    Secondly, you could replicate different VMs to different storage locations to perform some of the disk balancing you are trying to perform.  Lastly, you could copy the vhd file to a different location
    before starting the VM.
    .:|:.:|:. tim
    Hi Tim,
    thanks for the reply. Sorry, but I had some other tasks to take care of, so I wasn't paying enough attention to this thread.
    The part I quoted from your reply sounds exactly like the action I'd like to perform, but as you pointed out before this should not be possible.
    How can I perform the action (replicating each VM to a storage location) as you mentioned secondly? To sum it up again:
    2x physical machines carrying severel HDDs
    8+ VMs spread to run on the 2x servers
    when setting up replication I can only set the storage-location from server A on B and vice versa B on A
    Thanks again for your reply.
    Cheers,
    Sebastian

  • Select top 2 sal from emp for each deptno - urgent

    I want to retrieive the top 2 sal for each deptno; Can you please help
    Thanks in advance

    I don't know if this is what you are looking for:
    scott@DBA> ed
    Wrote file afiedt.buf
      1  select empno,deptno,sal,drank
      2  from (select empno,deptno,sal,dense_rank() over(partition by deptno order by sal desc) as drank
      3*       from emp)
    scott@DBA> /
         EMPNO     DEPTNO        SAL      DRANK
          7839         10       5000          1
          7782         10       2450          2
          7934         10       1300          3
          7788         20       3000          1
          7902         20       3000          1
          7566         20       2975          2
          7876         20       1100          3
          7369         20        800          4
          4109         20        800          4
          7698         30       2850          1
          7499         30       1600          2
          7844         30       1500          3
          7521         30       1250          4
          7654         30       1250          4
          7900         30        950          5
    15 rows selected.Get only the ones that are in rank 1 and 2
    scott@DBA> ed
    Wrote file afiedt.buf
      1  select empno,deptno,sal,drank
      2  from (select empno,deptno,sal,dense_rank() over(partition by deptno order by sal desc) as drank
      3        from emp)
      4* where drank in (1,2)
    scott@DBA> /
         EMPNO     DEPTNO        SAL      DRANK
          7839         10       5000          1
          7782         10       2450          2
          7788         20       3000          1
          7902         20       3000          1
          7566         20       2975          2
          7698         30       2850          1
          7499         30       1600          2
    7 rows selected.Create view for doing a simplified way to select data.
    scott@DBA> create view top_2_emp_by_sal as
      2  select empno,deptno,sal,drank
      3  from (select empno,deptno,sal,dense_rank() over(partition by deptno order by sal desc) as drank
      4        from emp)
      5  where drank in (1,2);
    View created.
    scott@DBA> select * from top_2_emp_by_sal;
         EMPNO     DEPTNO        SAL      DRANK
          7839         10       5000          1
          7782         10       2450          2
          7788         20       3000          1
          7902         20       3000          1
          7566         20       2975          2
          7698         30       2850          1
          7499         30       1600          2
    7 rows selected.Message was edited by:
    Delfino Nunez

  • SQL Selecting the first and last entries for each day

    Hello SQL experts,
    I hope you can help with this.. I have a table (could have 1M or more rows in it) see structure below. I am looking to get the first and last date/times for each employee for each day. I also need the location GUID for the first read.
    EmployeeGUID (uniqueidentifier datatype)
    LocationGUID (uniqueidentifier datatype)
    DateTime (DateTime datatype)
    12345678-0000-0000-0000-000000000000
    11111111-0000-0000-0000-000000000000
    04/12/2014 07:00:01
    12345678-0000-0000-0000-000000000000
    22222222-0000-0000-0000-000000000000
    04/12/2014 10:40:05
    12345678-0000-0000-0000-000000000000
    22222222-0000-0000-0000-000000000000
    04/12/2014 17:04:02
    44422222-0000-0000-0000-000000000000
    22222222-0000-0000-0000-000000000000
    04/14/2014 08:00:00
    44422222-0000-0000-0000-000000000000
    22222222-0000-0000-0000-000000000000
    04/14/2014 14:00:03
    44422222-0000-0000-0000-000000000000
    33333333-0000-0000-0000-000000000000
    04/15/2014 07:49:00
    44422222-0000-0000-0000-000000000000
    11111111-0000-0000-0000-000000000000
    04/15/2014 09:00:01
    This would be the ideal output (I can do without the TotalTimeInHours):
    EmployeeGUID (uniqueidentifier datatype)
    LocationGUID (uniqueidentifier datatype)
    FirstRead (DateTime datatype)
    LastRead (DateTime datatype)
    TotalTimeInHours
    12345678-0000-0000-0000-000000000000
    11111111-0000-0000-0000-000000000000
    04/12/2014 07:00:01
    04/12/2014 17:04:02
    Total in hours between the first and last read.
    44422222-0000-0000-0000-000000000000
    22222222-0000-0000-0000-000000000000
    04/14/2014 08:00:00
    04/14/2014 14:00:03
    44422222-0000-0000-0000-000000000000
    33333333-0000-0000-0000-000000000000
    04/15/2014 07:49:00
    04/15/2014 09:00:01
    I would post what I have tried so far but I have been trying many different types of queries over the last few days. In short I need the employees first and last reads for each date. They could have many entries per date or just 1. I am certain that this
    is a trivial thing for a SQL expert but not trivial for me :).
    Thank you in advance!

    Thank you!
    This is almost what I need. The LocationGUID has to be included in the output. When I include it, I have to put it in the Group By clause. When I do that the reads are based on the LocationGUID (see below).
    ** I added a few more data entries and included the LocationGUID in the output.
    ***** SQL ***********
    CREATE TABLE test(  EmployeeGUID  uniqueidentifier, LocationGUID  uniqueidentifier, DateTimeCol  DateTime )Insert into test values
    ('12345678-0000-0000-0000-000000000000','11111111-0000-0000-0000-000000000000','04/12/2014 07:00:01')
    ,('12345678-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/12/2014 10:40:05')
    ,('12345678-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/12/2014 17:04:02')
    ,('12345678-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/12/2014 19:00:00')
    ,('44422222-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/14/2014 08:00:00')
    ,('44422222-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/14/2014 14:04:03')
    ,('44422222-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/15/2014 07:49:00')
    ,('44422222-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/15/2014 09:00:01')
    ,('12345678-0000-0000-0000-000000000000','11111111-0000-0000-0000-000000000000','04/13/2014 10:40:05')
    ,('12345678-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/13/2014 17:04:02')
    ,('12345678-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/13/2014 19:00:00')
    ;with mycte as (
    SELECT *, row_number() OVER(partition by EmployeeGUID, Cast(DateTimeCol as date)  Order by  DateTimeCol) rnASC,
     row_number() OVER (partition by EmployeeGUID, Cast(DateTimeCol as date)  Order by  DateTimeCol DESC) rnDESC
    FROM    test)
    Select EmployeeGUID ,Cast(DateTimeCol as date) dt,LocationGUID,
    Max(Case when rnASC=1 Then DateTimeCol End) minDateTimeCol
    ,Max(Case when rnDESC=1 Then DateTimeCol End ) maxDateTimeCol
    ,Datediff(minute, Max(Case when rnASC=1 Then DateTimeCol End) ,Max(Case when rnDESC=1 Then DateTimeCol End ) )/60.0  TotalTimeInHours
    from mycte
    Group by EmployeeGUID, LocationGUID,Cast(DateTimeCol as date)
    Order by dt,EmployeeGUID
    drop TABLE test
    **** OUTPUT **********
    EmployeeGUID
    dt
    LocationGUID
    minDateTimeCol
    maxDateTimeCol
    TotalTimeInHours
    12345678-0000-0000-0000-000000000000
    2014-04-12
    11111111-0000-0000-0000-000000000000
    2014-04-12 07:00:01.000
    NULL
    NULL
    12345678-0000-0000-0000-000000000000
    2014-04-12
    22222222-0000-0000-0000-000000000000
    NULL
    2014-04-12 19:00:00.000
    NULL
    12345678-0000-0000-0000-000000000000
    2014-04-13
    11111111-0000-0000-0000-000000000000
    2014-04-13 10:40:05.000
    NULL
    NULL
    12345678-0000-0000-0000-000000000000
    2014-04-13
    22222222-0000-0000-0000-000000000000
    NULL
    2014-04-13 19:00:00.000
    NULL
    44422222-0000-0000-0000-000000000000
    2014-04-14
    22222222-0000-0000-0000-000000000000
    2014-04-14 08:00:00.000
    2014-04-14 14:04:03.000
    6.066666

Maybe you are looking for

  • [PART SOLVED] Random j, k characters appearing on lines. A vim issue?

    Hi There, I recently noticed that when scrolling around a file using the keys j and k in normal mode that random j and k characters appear at the end of lines. Initially I thought this was a terminal issue so I switched terminals, no luck. I removed

  • Plz help me design this query

    Hi, Can you'll please help me with this query. Here is a little bit of background: One title can have multiple items associated with it. Table: TITLE has the master list of titles. TITLE_ID is the primary key. Table: ITEM has the master list of all i

  • How do I position a apDiv tag?

    Hi there, I am having trouble trying to position my apDiv tag (apDiv1). How do i position it so that when the browser window is resized, it stays directly under the words "quick links" Please see my page https://dl.dropbox.com/u/4966582/intranet/inde

  • ECC 6.0, BI & EP Installation & Config?

    Hi Experts,                 I need to install ECC 6.0 , BI and Portal, So i selected ECC and WAS ABAP,WAS JAVA, BI, EPCORE, EP. The installation completed successfully. I am able to login to ECC with clients 000,001 and unable to login to 800, 811 an

  • Flex Debugger - watching an expression continuously

    Hi all, Just a quick question about the Flex debugger (version 3). I have an AS class and I want to monitor a value continuously as the movie is playing. For instance, I might want to watch 'somebutton.x' or 'somebutton.width' - I don't want to use b