Query with 2 level of breaks overlapings, one with a distinct constraint

My boss asked me, for an Apex graph, to give for one day
every 10 min the number of UNIQUE people (id) connected in the last 30 minutes.
It is because this Unique ID count that I cannot solve this, but I am convinced it can be done using analytical or model clause.
The folllwiing test case perfectly emulate the set of data as they comes from Websphere logs:
--  We want :
--    One row every 10 minutes that gives the count of UNIQUE  ID
--        connected in the last 30 min before this point
-- in this test case we assume that at 08h00 one user connects
--     every second during one hour.
with v as (
  select trunc(dbms_random.value(1,2000)+1) id,
       trunc(sysdate) + 80/24 + level/86400 sec from           <- this is  a typo, I wanted 8/24
  dual connect by level < 3600
select id, to_char(sec,'YYYY-MM-DD HH24:MI:SS') from v
      ID   Time
       568 2011-07-23 08:48:19
      1057 2011-07-23 08:48:20
      1864 2011-07-23 08:48:21
      1500 2011-07-23 08:48:22
       917 2011-07-23 08:48:23
      1844 2011-07-23 08:48:24
       779 2011-07-23 08:48:25
       448 2011-07-23 08:48:26
       382 2011-07-23 08:48:27
       256 2011-07-23 08:48:28
      1821 2011-07-23 08:48:29
       872 2011-07-23 08:48:30
       658 2011-07-23 08:48:31
.Edited by: bpolarski on 20 juil. 2011 12:10 added typo comment

Hi Solomon
I don't think the numbers are correct. There are 1200 rows before 8:20, but your query is showing 1569 distinct sessions.
with v as (
           select  --+materialize
                    trunc(dbms_random.value(1,2000)+1) id,
                   trunc(sysdate) + 80/24 + level/86400 sec
             from  dual connect by level < 3600
select
    count(*),
    count(distinct id)
FROM
    v where sec <= TO_DATE('23/07/2011 08:20:00','dd/mm/yyyy hh24:mi:ss')
SQL> with v as (
  2             select  --+materialize
  3                      trunc(dbms_random.value(1,2000)+1) id,
  4                     trunc(sysdate) + 80/24 + level/86400 sec
  5               from  dual connect by level < 3600
  6            )
  7  select
  8      count(*),
  9      count(distinct id)
10  FROM
11      v where sec <= TO_DATE('23/07/2011 08:20:00','dd/mm/yyyy hh24:mi:ss')
12  /
  COUNT(*) COUNT(DISTINCTID)
      1200               910I know this might not be the neatest way to get the result, but I think this is the correct one. I tried with analytics but I kept hitting problems with the ranges...
with v as (
           select  trunc(dbms_random.value(1,2000)+1) id,
                   trunc(sysdate) + 80/24 + level/86400 sec
             from  dual connect by level < 3600
SELECT
    sec_10_min,
    (   SELECT
            count(distinct l.id)
        FROM
            v l
        WHERE
            l.sec >= sec_10_min - NUMTODSINTERVAL(30,'MINUTE')
        AND
            l.sec <= sec_10_min
     ) ct
FROM
    (   SELECT
            sec_10_min
        FROM
                select  trunc(sec,'HH') + trunc(to_char(sec,'MI') / 10) / 144 sec_10_min
                from  v
                WHERE
                    rownum > 0
        group by
            sec_10_min
  order by sec_10_min
SQL> with v as (
  2             select  trunc(dbms_random.value(1,2000)+1) id,
  3                     trunc(sysdate) + 80/24 + level/86400 sec
  4               from  dual connect by level < 3600
  5            )
  6  SELECT
  7      sec_10_min,
  8      (   SELECT
  9              count(distinct l.id)
10          FROM
11              v l
12          WHERE
13              l.sec >= sec_10_min - NUMTODSINTERVAL(30,'MINUTE')
14          AND
15              l.sec <= sec_10_min
16       ) ct
17  FROM
18      (   SELECT
19              sec_10_min
20          FROM
21              (
22                  select  trunc(sec,'HH') + trunc(to_char(sec,'MI') / 10) / 144 sec_10_min
23                  from  v
24                  WHERE
25                      rownum > 0
26              )
27          group by
28              sec_10_min
29      )
30    order by sec_10_min
31  /
SEC_10_MIN                  CT
23/07/2011 08:00:00          0
23/07/2011 08:10:00        511
23/07/2011 08:20:00        897
23/07/2011 08:30:00       1176
23/07/2011 08:40:00       1179
23/07/2011 08:50:00       1188HTH
David
Edited by: Bravid on Jul 20, 2011 2:43 PM
Edited by: Bravid on Jul 20, 2011 2:48 PM
Updated NLS to show times in the output

Similar Messages

  • I have two apple ID's, one with all my apps and one with only Mavericks. Will Mavericks update automatically if i'm not logged in to the apple ID I used to download it?

    I have two apple ID's, one with all my apps and one with only Mavericks. Will Mavericks update automatically if i'm not logged in to the apple ID I used to download it?

    Some things are mixed up here, seemingly...
    I seem to have two Apple ID's attached to my e-mail.
    An Apple ID is a valid email address, apparently. How can those be "attached to your email"... what email?
    Facetime will not verify my e-mail address because it is associated with the other account.
    This doesn't make sense. You can register multiple, even non-Apple-ID, email addresses and their aliases with FaceTime.
    So, maybe you can explain your problem better - what you want and the steps you've taken and what you have so far. If something doesn't work, please tell the exact error message, too.

  • HT1310 when i starst my mac i get a flashing folder with a question mark. i tried rebooting and holding the option button then i get 2 boxes, one with a refresh arrow and one with a forward arrow neither of them seem to do anything. now what

    when i starst my mac i get a flashing folder with a question mark. i tried rebooting and holding the option button then i get 2 boxes, one with a refresh arrow and one with a forward arrow neither of them seem to do anything. now what

    Here is an article that describes what it is supposed to do:
    Startup Manager: How to select a startup volume
    If no Volumes are shown, it is telling you there are no potentailly bootable Volumes attached. That means your boot drive has died or the bootable image on it is unrecognizable.
    What Mac Pro ? by year, GHz, number of processors, screen size?
    What Mac OS X ?

  • I have a MBP 15" with iPhoto 9. When right clicking on icon in dock 3 iPhoto libraries come up; one empty, one with 35,000 photos and one with 30,000 photos.  How can I delete the empty one and merge the other two without getting duplicates?

    I have a MBP 15" with Iphoto 9.  When I right click on icon in dock 3 iPhoto libraries come up; one empty, one with 35,000 photos and one with 30,000 photos.  How can I delete the empty library and merge the other two without getting duplicates?

    You can delete the empty one by dragging it to the trash ( test everything before emptying the trash)
    Merging libraries requires iPhoto Library Manager - http://www.fatcatsoftware.com/iplm/ -  it is the only current solution to merging libraries
    LN

  • Mac Pro with two graphic card each one with two dvi output, can I extend deskop to three outputs?

    Mac Pro with two graphic card each one with two dvi output, can I extend deskop to three outputs?

    MAC OS 10.7.4  3.2GHz Quad-Core Intel Xeon processors, 12GB  of 800MHz DDR2 and 2 ATI Radeon HD 2600 XT 256MB (two dual-link DVI ports) . The problem is, I woul like to use one output as main and the three others as secondary or extended desktop but the system don't allow me use two diferent video cards this way.

  • How do I move all my settings from my old computer with Vista to a New one with Windows 7 ? I'm using V. 14.0.1 on both Systems

    Hello All,
    How do I move all my Settings & Bookmarks from my 5 year old Computer running Vista and Firefox V. 14.0.1 , to my New Computer with Windows 7 and also Firefox 14.0.1 ?
    Thank you very much.

    You can copy your Firefox profile from one computer to the other and continue working with almost no changes :)
    [[Back up and restore information in Firefox profiles]]
    A really easy way to do this is the following:
    #Click the Start button, type %APPDATA% into the search bar, press Enter (on your old PC)
    #Right click on the Mozilla folder, copy to a thumb drive (or something you can use to transfer it to your new PC)
    #Go to %APPDATA% the same way on your new computer
    #If the Mozilla folder already exists, I'd either delete it or rename it
    #Paste the Mozilla folder into the same place on your new PC
    #then upgrade to Firefox 15
    You can also use Firefox Sync. [[How do I set up Firefox Sync?]]

  • Wireless router w/ four computers. Three wireless with 2XP and 1Vista, and one with wired XP

     I have a home network that is encrypted. On this network I have four computers.
     I have three computers that are set up on wireless.  One is running Windows Vista and the other two are running XP.
    The last computer on the network is wired and is running XP.
    Very frequently, my network on linksys adviser tells me that I have installed a new router. I definitely did nothing of the sort so why does it do this?
    I have to shut down and resart both the router (I turn it off and on and unplug it for about 20 seconds and then turn it back on) and the computer when this happens and then after that, it suddenly works fine.
    I noticed today that I turned on the wired computer, connected to the internet on the regular encrypted network , then I tried to connect to the network on the wireless computer as well. On the wireless one, the network was not even detected, the name of the network wasn't even there anymore.
    So, I did the same thing I usually do by restarting both computers, unplugging the router, plugging it back in and trying to connect again but this time it still kept saying that I installed a new router and then even the first computer that I HAD been connected to didn't connect this time.
    Why did it just "drop" my network connection and make it go away? How is this possible? I am the only one on ALL of these computers and I did NOT change to a new router or do anything to it at all other than turn it on and try to go to the internet.
    The network is not even listed as being on my computer anymore .
    Please help.
    Thank you.

    Well do you get this error message after running Linksys Advisor, or without it. If you are running the Linksys Advisor, then first of all I don’t understand why you are running this software. It is meant for configuring the router and every time you run it, it’s a new router for this software. If you are not running it then there’s an issue, as this is a tool that can be used to configure the router and not an application that can be kept running all the time. Let me know exactly when you are getting this message, along with the modem no. About your network, you need to reconfigure this router again and setup all the connections with new settings.

  • 10.4.11 Install with two users working but one with a blue screen

    On installation of 10.4.11 two of the users are working just fine but one give only a blue screen. My next thought is to try going back to 10.4 and doing an archive and install. Any other thoughts? Thanks.

    If either good user account is an admin user, log into it, delete the bad user account, saving user data (that creates a /Users/Disabled Users/disk image), recreate the account, using the same username/password account, log into it, mount the disk image, and merge the data.

  • When I click on a link that is in an email 2 Firefox windows open, one with the link url and one with my homepage.

    Since the last time Firefox updated itself ,,, when I click on a link in an email I've recieved 2 windows open. One is my Google homepage and the other is the link url site.
    == This happened ==
    Every time Firefox opened
    == a link in an email is clicked.

    See [https://bugzilla.mozilla.org/show_bug.cgi?id=531552 Bug 531552] - Firefox 3.6b opens two windows when opening external links
    '(please do not comment in bug reports)'

  • When I click on a link in another application, Firefox opens up two windows, one with my home page and one with my link. How do I turn this off so that I only get one window

    Mac OS10.6.4

    That is this bug:<br />
    https://bugzilla.mozilla.org/show_bug.cgi?id=531552 - Firefox 3.6b opens two windows when opening external links
    (please do not comment in bug reports)

  • LMS duplictae events; one with dns and one with dns(ip) in component name

    Hello all,
    we have LMS 4.2 installed and added devices;
    Now if for example a device is not reachable we get two messages with same failure ;
    only the componente name is different
    -     one event with "dns" in component name
    -     one with "dns(ip)"  in component name
    dns == hostname
    Thans in advance

    Is it possible you have the devices twice in fault management?
    Once with the IP address as their name and once with their dns name?
    If that is the case you will find the same in the DCR.
    Try to delete the devices that only have ip address as name.
    Cheers,
    Michel

  • Query with level

    Hi,
    I've this table:
    CREATE TABLE TAB_LEVEL
    COD VARCHAR2(255 BYTE),
    COD_DESCR VARCHAR2(255 BYTE),
    COD_LEVEL VARCHAR2(255 BYTE),
    COD_FATHER VARCHAR2(255 BYTE)
    with data:
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50000135', 'WINE', '1', '50000135');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50033789', 'CHIEF', '2', '50000135');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50039579', 'BUSINESS UNIT CONSUMER WINE', '3', '50033789');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50033858', 'SALES', '4', '50039579');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50015464', 'LOGISTICS', '5', '50033858');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50015740', 'TECHNICAL ASSISTANCE AND IND. LOG.', '6', '50015464');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50020150', 'ITNET SrL', '1', '50020150');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50033764', 'OPERATIONS', '2', '50020150');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50033765', 'INFORMATION TECHNOLOGY', '3', '50033764');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50000135', 'WINE', '1', '50000135');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50023726', 'HUMAN RESOURCES', '2', '50000135');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50021773', 'EMPLOYEE', '3', '50023726');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50017605', 'NORM', '4', '50021773');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50000135', 'WINE', '1', '50000135');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50023726', 'HUMAN RESOURCES', '2', '50000135');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50021773', 'EMPLOYEE', '3', '50023726');
    Insert into TAB_LEVEL (COD, COD_DESCR, COD_LEVEL, COD_FATHER) Values ('50017605', 'NORM', '4', '50021773');
    COMMIT;
    I'd like to write a query for each cod_descr I get one cod_level
    for example: cod_level=3 I get cod_desc1 - cod_descr2 - cod_descr3
    cod_level=6 I get cod_desc1 - cod_descr2 - cod_descr3 - cod_desc4 - cod_descr5 - cod_descr6
    below the output that I want:
    CREATE TABLE TAB_LEVEL_NEW
    COD VARCHAR2(255 BYTE),
    COD_DESCR1 VARCHAR2(255 BYTE),
    COD_DESCR2 VARCHAR2(255 BYTE),
    COD_DESCR3 VARCHAR2(255 BYTE),
    COD_DESCR4 VARCHAR2(255 BYTE),
    COD_DESCR5 VARCHAR2(255 BYTE),
    COD_DESCR6 VARCHAR2(255 BYTE),
    COD_LEVEL VARCHAR2(255 BYTE),
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50000135', 'WINE', NULL, NULL, NULL,
    NULL, NULL, 1);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50033789', 'WINE', 'CHIEF', NULL, NULL,
    NULL, NULL, 2);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50039579', 'WINE', 'CHIEF', 'BUSINESS UNIT CONSUMER WINE', NULL,
    NULL, NULL, 3);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50033858', 'WINE', 'CHIEF', 'BUSINESS UNIT CONSUMER WINE', 'SALES',
    NULL, NULL, 4);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50015464', 'WINE', 'CHIEF', 'BUSINESS UNIT CONSUMER WINE', 'SALES',
    'LOGISTICS', NULL, 5);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50015740', 'WINE', 'CHIEF', 'BUSINESS UNIT CONSUMER WINE', 'SALES',
    'LOGISTICS', 'TECHNICAL ASSISTANCE AND IND. LOG.', 6);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50020150', 'ITNET SrL', NULL, NULL, NULL,
    NULL, NULL, 1);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50033764', 'ITNET SrL', 'OPERATIONS', NULL, NULL,
    NULL, NULL, 2);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50033765', 'ITNET SrL', 'OPERATIONS', 'INFORMATION TECHNOLOGY', NULL,
    NULL, NULL, 3);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50000135', 'WINE', NULL, NULL, NULL,
    NULL, NULL, 1);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50023726', 'WINE', 'HUMAN RESOURCES', NULL, NULL,
    NULL, NULL, 2);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50021773', 'WINE', 'HUMAN RESOURCES', 'EMPLOYEE', NULL,
    NULL, NULL, 3);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values
    ('50017605', 'WINE', 'HUMAN RESOURCES', 'EMPLOYEE', 'NORM',
    NULL, NULL, 4);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50000135', 'WINE', NULL, NULL, NULL,
    NULL, NULL, 1);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50023726', 'WINE', 'HUMAN RESOURCES', NULL, NULL,
    NULL, NULL, 2);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50021773', 'WINE', 'HUMAN RESOURCES', 'EMPLOYEE', NULL,
    NULL, NULL, 3);
    Insert into TAB_LEVEL_NEW (COD, COD_DESCR1, COD_DESCR2, COD_DESCR3, COD_DESCR4, COD_DESCR5, COD_DESCR6, COD_LEVEL) Values ('50017605', 'WINE', 'HUMAN RESOURCES', 'EMPLOYEE', 'NORM',
    NULL, NULL, 4);
    COMMIT;
    How can I write my query to get the values into TAB_LEVEL_NEW table from TAB_LEVEL table??
    Thanks in advance!

    Hi,
    Raf Royal wrote:
    Frank,
    I need query not insert, In that case, post the results you want from the query.
    The solution you want will be the query part of the INSERT statement.
    I tried this:
    SELECT DISTINCT
         cod
    ,     REGEXP_SUBSTR (path, '[^/]+', 1, 1)
    ,     REGEXP_SUBSTR (path, '[^/]+', 1, 2)
    ,     REGEXP_SUBSTR (path, '[^/]+', 1, 3)
    ,     REGEXP_SUBSTR (path, '[^/]+', 1, 4)
    ,     REGEXP_SUBSTR (path, '[^/]+', 1, 5)
    ,     REGEXP_SUBSTR (path, '[^/]+', 1, 6)
    ,     cod_level
    FROM
         SELECT     cod
         ,     SYS_CONNECT_BY_PATH (cod_descr, '/')     AS path
         ,     cod_level
         ,     LEVEL                         AS lvl
         FROM     tab_level
         START WITH     cod_level     = '1'
         CONNECT BY     cod_father     = PRIOR cod
              AND     cod_father     != cod
    )Please don't post unformatted code, especially when using regular expressions, because some of the special characters common in regular expressions are treated as markup by this site if not enclosed in tags.
    but I get this error:
    ORA-30004 when using SYS_CONNECT_BY_PATH function, cannot have seperator as part of column value
    I'm using this query on tab_level with 10000 records.
    have you any idea for this error?That error occurs if the 2nd argument to SYS_CONNECT_BY_PATH ('/' in my example) ever occurs in the 1st argument (cod_descr).
    Instead of using '/', use some character that never occurs in cod_descr, maybe '~' or ';' .  Remember to change the '/'s in all the REGEXP_SUBSTR calls to the same demiiter.
    You don't have to use a single-character delimiter in SYS_CONNECT_BY_PATH, put then the REGEG_SUBSTR calls will probably need to be more complicated.
    You still haven't explained why you want the results you requested.
    I think you can get those exact results by joining your current table to the query I posted, but it's unclear if that's what you really want.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • I have SSRS parametarized report in that one data set have repeated values with query parameter . but while am mapping that query parameter to report parameter i need to pass distinct values. How can i resolve this

    I have SSRS parametarized report in that one data set have repeated values with query parameter . but while am mapping that query
    parameter to report parameter i need to pass distinct values. How can i resolve this

    Hi nancharaiah,
    If I understand correctly, you want to pass distinct values to report parameter. In Reporting Service, there are only three methods for parameter's Available Values:
    None
    Specify values
    Get values from a query
    If we utilize the third option that get values from a dataset query, then the all available values are from the returns of the dataset. So if we want to pass distinct values from a dataset, we need to make the dataset returns distinct values. The following
    sample is for your reference:
    Select distinct field_name  from table_name
    If you have any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • QUERY FOR CUSTOMERS FULL DEBIT AND CREDIT WITH CLOSING BALANCE

    Hi Friends,
       I need query for CUSTOMERS FULL DEBIT AND CREDIT WITH CLOSING BALANCE for selection criteria from date and to date.
       I know the Trial Balance Report will sort out this issue... but i need routeday wise report
    1. Business Partner Master Data - i created one UDF field called U_Routeday (MONDAY, TUESDAY, WEDNESDAY,THURSDAY,FRIDAY)
    2. The query should be like selection criteria 
                                  - Routeday [%0]
                                  - Posting Date [%1]                           
                                  - Posting Date [%2]
    CardCode
    Debit
    Credit
    Balance
    D10503
    25031.50
    24711.50
    2962.00
    D10641
    5466.00
    7460.00
    285.00
    D10642
    2866.00
    142.00
    give any helpful query ASAP... Thanks in advance

    Hi,
    Try this query:
    Declare
    @fromdate as datetime
    Declare
    @Todate as datetime
    Declare
    @Code as nvarchar(25)
    set
    @fromdate = ( select min(Ta.[RefDate]) from OJDT ta where
    Ta.[RefDate] >= [%0])
    set
    @Todate = ( select max(Tb.[RefDate]) from OJDT tb where Tb.[RefDate]
    <= [%1])
    set
    @code = (select max(Tc.[ShortName]) from JDT1 tC where Tc.[ShortName]
    = [%2])
    SELECT
    [Name] as AcctName, [Jan]= sum([1]), [Feb]= sum([2]), [Mar]=
    sum([3]), [Apr]= sum([4]),  [May]= sum([5]), [June]= sum([6]),
    [July]= sum([7]), [Aug]= sum([8]), [Sept]= sum([9]), [Oct]=
    sum([10]), [Nov]= sum([11]), [Dec]= sum([12]), total = sum
    (isnull([1],0)+ isnull([2],0) + isnull([3],0) + isnull([4],0) +
    isnull([5],0) + isnull([6],0) + isnull([7],0) + isnull([8],0) +
    isnull([9],0)+ isnull([10],0) + isnull([11],0) + isnull([12],0))
    from
    (SELECT
    T0.[ShortName] as Name, sum(T0.[Debit]-T0.[Credit]) as T,
    month(T2.[RefDate]) as month FROM JDT1 T0  INNER JOIN OACT T1 ON
    T0.Account = T1.AcctCode INNER JOIN OJDT T2 ON T0.TransId =
    T2.TransId WHERE T2.[RefDate] between @fromdate and @todate and
    T0.[ShortName]  = @code  GROUP BY T0.[ShortName],T2.[RefDate] ) S
    Pivot
    (sum(T)
    For  Month IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) P
    group
    by [Name],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12]
    Let me know your result.
    Thanks & Regards,
    Nagarajan

  • IPod Touch conflict with HP 6500 All-in-One printer...

    Does anyone know of anyone who has an iPod Touch installed with an HP all-in-one printer and running under Windows 7 64 bit? If so I'd like to hear from them and see if I can pick their brains a bit. In fact, I'd like to hear from anyone who has an iPod Touch working with an HP all-in-one on a desktop system, no matter the OS.
    Originally I tried to get them to work together under a 32 bit Windows 7 Premium build on an MSI G31M3-F V2 mobo but couldn't get the iPod and the All-in-One to work together. Either the iPod wouldn't synch or the printer would disconnect.
    Yesterday I started with a Windows 7 Ultimate 64 bit build on an Asus P5Q-EM mobo with just the HP 6500 All-in-One and the printer and all of its functions were working perfectly.
    Then I plugged in the iPod, after having installed the newest 64 bit version of iTunes, and it detected the device but wouldn't complete the driver installation. I powered down the HP 6500 and the iPod installation completed.
    I then turned the printer on and it appeared to work but the iPod wouldn't complete the sync process unless I turned the printer off.
    Then I changed the drive letter of the HP all-in-one's integrated card reader from "E:" to "G:" and rebooted and it appeared that everything was working. I brought the scanner up but didn't actually scan anything but, still, no disconnect messages. Finally, success I thought. Silly me...
    Today my daughter tried to send a fax from the computer. It started the scan, stopped after only partially scanning and said that the printer was disconnected.
    She then rebooted and tried to scan a photo and it did essentailly the same thing -- a partial scan, froze, and then reported the printer offline.
    Uninstalling the iPod Touch device resulted in the printer coming back online and all functions working perfectly.
    There is clearly a conflict at the device/driver assignment level and I don't know if its even anything that I can fix.
    This should not be this hard.
    Has anyone any experience with the iPod Touch running on a desktop that also has an HP All-in-One device installed?

    Finally installed a completely new OS and then, before doing anything else, installed iTunes and connected the iPod. Installed everything else with the HP printer being the very last thing.
    Wa La... Worked as advertised...

Maybe you are looking for

  • How do I import a jpeg image into my mail signature so that it wont separate when it gets to the receiving email

    How do I import a jpg image into my mail signature box so that it wont separate into an attachment when it gets to the receiving mail box.  We have a company logo and when I send it to someone it does not show up under our address but rather as an at

  • Unable to Install Itunes for iPod Touch

    My husband was just given an iPod Touch 16gb and he went to install it to his computer. He has an older version of itunes on there for listening to on his pc. When updating it he gets this error message."Could not open key. HKEYLOCALMACHINE\Software\

  • Help on SQL Loader When Clause

    I have 2 Oracle tables of exact same structure. ENO NUMBER PARENT NUMBER CHILD NUMBER ENAME VARCHAR2 (50 Byte) ADDRESS VARCHAR2 (50 Byte) CITY VARCHAR2 (50 Byte) SRCFILENAME VARCHAR2 (50 Byte) SDATE VARCHAR2 (400 Byte) Current_Load VARCHAR2 (1 Byte)

  • How to move all files, and authorisations...

    Hi. I have been making music on a G4 powerbook for a while, but now i have got an imac G5 20" machine ready and waiting for me. The powerbook is running 10.3.9 and the imac will be running the latest tiger os. I need to find out the most painless way

  • Automate QA testting Oracle ADF applications

    Is there a method/tool to automate QA testing on ADF fusion web applications.