Need Help With Query Using Aggregation

If I have a table, defined like this:
CREATE TABLE range_test
range_id NUMBER(20) NOT NULL,
grade CHAR(1) NOT NULL,
lower_bound_of_range NUMBER(5,2) NOT NULL,
upper_bound_of_range NUMBER(5,2) NOT NULL,
received_date_time_stamp TIMESTAMP DEFAULT SYSTIMESTAMP NOT NULL
And I wanted to query the table to find the range associated with the last inserted row for each 'grade' (e.g. 'A', 'B', 'C', etc), how would I go about that?
I want something like the following, but I know that this won't work right:
SELECT
grade,
lower_bounding_of_range,
upper_bounding_of_range,
max(received_date_time_stamp)
FROM
range_test GROUP BY received_date_time_stamp;
Thanks for your help. . .I'm frustrating myself with this one and I think it should be possible without having to use PL/SQL (i.e. SQL aggregate functions or sub-queries should work).

Perhaps something along the lines of...
SQL> ed
Wrote file afiedt.buf
  1  select deptno, empno, ename, hiredate
  2  from emp
  3* order by deptno, empno
SQL> /
    DEPTNO      EMPNO ENAME      HIREDATE
        10       7782 CLARK      09-JUN-1981 00:00:00
        10       7839 KING       17-NOV-1981 00:00:00
        10       7934 MILLER     23-JAN-1982 00:00:00
        20       7369 SMITH      17-DEC-1980 00:00:00
        20       7566 JONES      02-APR-1981 00:00:00
        20       7788 SCOTT      19-APR-1987 00:00:00
        20       7876 ADAMS      23-MAY-1987 00:00:00
        20       7902 FORD       03-DEC-1981 00:00:00
        30       7499 ALLEN      20-FEB-1981 00:00:00
        30       7521 WARD       22-FEB-1981 00:00:00
        30       7654 MARTIN     28-SEP-1981 00:00:00
        30       7698 BLAKE      01-MAY-1981 00:00:00
        30       7844 TURNER     08-SEP-1981 00:00:00
        30       7900 JAMES      03-DEC-1981 00:00:00
14 rows selected.
SQL> ed
Wrote file afiedt.buf
  1  select deptno, empno, ename, hiredate
  2  from (
  3        select deptno, empno, ename, hiredate
  4              ,row_number() over (partition by deptno order by hiredate desc) as rn
  5        from emp
  6       )
  7  where rn = 1
  8* order by deptno, empno
SQL> /
    DEPTNO      EMPNO ENAME      HIREDATE
        10       7934 MILLER     23-JAN-1982 00:00:00
        20       7876 ADAMS      23-MAY-1987 00:00:00
        30       7900 JAMES      03-DEC-1981 00:00:00
SQL>

Similar Messages

  • Need help with session using dreamweaver

    have created a login page (php/mysql) with username and
    password boxes. when the form is submitted the mainpage loads up.
    i want the main page to be specific to that user, so i want
    their name to appear in the first line. eg.. Welcome back 'David'
    I read a tutorial in the past that tought me to send the
    users id in the URL and then create a record set on the mainpage
    that was filtered by the URL parameter.
    I have forgotten how to do this and the tutorial is no longer
    available on Adobe's site.
    I tried that with
    $_SESSION['MM_Username'] = $loginUsername; \\ in first page
    then
    echo $_SESSION["MM_username"]; \\in second page, but the
    problem is that is not showing user name.
    i need help with that please!
    can anyone tell me how to do this? Thanks in advance,
    AM

    IN the second page, you have to make sure that the session
    has been started.
    Put this at the very top of the page -
    <?php if (!isset($_SESSION)) session_start(); ?>
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Alidad" <[email protected]> wrote in
    message
    news:g184i4$jgf$[email protected]..
    > have created a login page (php/mysql) with username and
    password boxes.
    > when
    > the form is submitted the mainpage loads up.
    >
    > i want the main page to be specific to that user, so i
    want their name to
    > appear in the first line. eg.. Welcome back 'David'
    >
    > I read a tutorial in the past that tought me to send the
    users id in the
    > URL
    > and then create a record set on the mainpage that was
    filtered by the URL
    > parameter.
    >
    > I have forgotten how to do this and the tutorial is no
    longer available on
    > Adobe's site.
    >
    > I tried that with
    > $_SESSION['MM_Username'] = $loginUsername; \\ in first
    page then
    > echo $_SESSION["MM_username"]; \\in second page, but
    > the
    > problem is that is not showing user name.
    >
    > i need help with that please!
    >
    > can anyone tell me how to do this? Thanks in advance,
    >
    > AM
    >

  • Need help with query joining several tables into a single return line

    what i have:
    tableA:
    puid, task
    id0, task0
    id1, task1
    id2, task2
    tableB:
    puid, seq, state
    id0, 0, foo
    id0, 1, bar
    id0, 2, me
    id1, 0, foo
    id2, 0, foo
    id2, 1, bar
    tableC:
    puid, seq, date
    id0, 0, 12/21
    id0, 1, 12/22
    id0, 2, 12/22
    id1, 0, 12/23
    id2, 0, 12/22
    id2, 1, 12/23
    what i'd like to return:
    id0, task0, 12/21, 12/22, 12/22
    id1, task1, 12/23, N/A, N/A
    id2, task2, 12/22, 12/23, N/A
    N/A doesn't mean return the string "N/A"... it just means there was no value, so we don't need anything in this column (null?)
    i can get output like below through several joins, however i was hoping to condense each "id" into a single line...
    id0, task0, 12/21
    id0, task0, 12/22
    id0, task0, 12/23
    id1, task1, 12/23
    is this possible fairly easily?
    Edited by: user9979830 on Mar 29, 2011 10:53 AM
    Edited by: user9979830 on Mar 29, 2011 10:58 AM

    Hi,
    Welcome to the forum!
    user9979830 wrote:
    what i have:...Thanks for posting that so clearly!
    Whenever you have a question, it's even better if you post CREATE TABLE and INSERT statements for your sample data, like this:
    CREATE TABLE     tablea
    (       puid     VARCHAR2 (5)
    ,     task     VARCHAR2 (5)
    INSERT INTO tablea (puid, task) VALUES ('id0',  'task0');
    INSERT INTO tablea (puid, task) VALUES ('id1',  'task1');
    INSERT INTO tablea (puid, task) VALUES ('id2',  'task2');
    CREATE TABLE     tablec
    (       puid     VARCHAR2 (5)
    ,     seq     NUMBER (3)
    ,     dt     DATE          -- DATE is not a good column name
    INSERT INTO tablec (puid, seq, dt) VALUES ('id0',  0,  DATE '2010-12-21');
    INSERT INTO tablec (puid, seq, dt) VALUES ('id0',  1,  DATE '2010-12-22');
    INSERT INTO tablec (puid, seq, dt) VALUES ('id0',  2,  DATE '2010-12-22');
    INSERT INTO tablec (puid, seq, dt) VALUES ('id1',  0,  DATE '2010-12-23');
    INSERT INTO tablec (puid, seq, dt) VALUES ('id2',  0,  DATE '2010-12-22');
    INSERT INTO tablec (puid, seq, dt) VALUES ('id2',  1,  DATE '2010-12-23');This way, people can re-create the problem and test their ideas.
    It doesn't look like tableb plays any role in this problem, so I didn't post it.
    Explain how you get the results from that data. For example, why do you want this row in the results:
    PUID  TASK  DT1        DT2        DT3
    id0   task0 12/21/2010 12/22/2010 12/22/2010rather than, say
    PUID  TASK  DT1        DT2        DT3
    id0   task0 12/22/2010 12/21/2010 12/22/2010? Does 12/21 have to go in the first column because it is the earliest date, or is it because 12/21 is related to the lowest seq value? Or do you even care about the order, just as long as all 3 dates are shown?
    Always say what version of Oracle you're uisng. The query below will work in Oracle 9 (and up), but starting in Oracle 11, the SELECT ... PIVOT feature could help you.
    i can get output like below through several joins, however i was hoping to condense each "id" into a single line... Condensing the output, so that there's only one line for each puid, sounds like a job for "GROUP BY puid":
    WITH     got_r_num     AS
         SELECT     puid
         ,     dt
         ,     ROW_NUMBER () OVER ( PARTITION BY  puid
                                   ORDER BY          seq          -- and/or dt
                           )         AS r_num
         FROM    tablec
    --     WHERE     ...     -- If you need any filtering, put it here
    SELECT       a.puid
    ,       a.task
    ,       MIN (CASE WHEN r.r_num = 1 THEN r.dt END)     AS dt1
    ,       MIN (CASE WHEN r.r_num = 2 THEN r.dt END)     AS dt2
    ,       MIN (CASE WHEN r.r_num = 3 THEN r.dt END)     AS dt3
    ,       MIN (CASE WHEN r.r_num = 4 THEN r.dt END)     AS dt4
    FROM       tablea    a
    JOIN       got_r_num r  ON   a.puid  = r.puid
    GROUP BY  a.puid
    ,            a.task
    ORDER BY  a.puid
    ;I'm guessing that you want the dates arranged by seq; that is, for each puid, the date related to the lowest seq comes first, regardless of whther that date is the earliest date for that puid or not. If that's not what you need, then change the analytic ORDER BY clause.
    This does not assume that the seq values are always consecutive integers (0, 1, 2, ...) for each puid. You can skip, or even duplicate values. However, if the values are always consecutive integers, starting from 0, then you could simplify this. You won't need a sub-query at all; just use seq instead of r_num in the main query.
    Here's the output I got from the query above:
    PUID  TASK  DT1        DT2        DT3        DT4
    id0   task0 12/21/2010 12/22/2010 12/22/2010
    id1   task1 12/23/2010
    id2   task2 12/22/2010 12/23/2010As posted, the query will display the first 4 dts for each puid.
    If there are fewer than 4 dts for a puid, the query will still work. It will leave some columns NULL at the end.
    If there are more than 4 dts for a puid, the query will still work. It will display the first 4, and ignore the others.
    There's nothing special about the number 4; you could make it 3, or 5, or 35, but whatever number you choose, you have to hard-code that many columns into the query, and always get that many columns of output.
    For various ways to deal with a variable number of pivoted coolumns, see the following thread:
    PL/SQL
    This question actually doesn't have anything to do with SQL*Plus; it's strictly a SQL question, and SQL questions are best posted on the "SQL and PL/SQL" forum:
    PL/SQL
    If you're not sure whether a question is more of a SQL question or a SQL*Plus question, then post it on the SQL forum. Many more people pay attention to that forum than to this one.

  • Need Help with Formula using SQL maybe

    I need help!  I work with Crystal reports XI and usually manage just fine with the Formula editor but his one I think will require some SQL and I am not good at that.
    We are running SQL 2000 I think (Enterprise Manager 8.0)  Our sales people schedule activities and enter notes for customer accounts.  Each is stored in a separate table.  I need to find activities that are scheduled 240 days into the future and show the most recent note that goes with the account for which that activity is scheduled.
    The two tables, Activities and History, share the an accountID field in common that links them to the correct customer account.   I want to look at dates in the Startdate.Activities field more than 240 days in the future and show the most recent note from the History table where the accountid's match. I figure my query will contain a join on AccountID.Activities and AccountID.History used with Max(completedate.History) but I do not understand how to word it.
    I would like to perform all this in crystal if possible.  I humbly request your help.
    Membery

    You SQL would look something like this...
    SELECT
    a.AccountID,
    a.BlahBlahBlah, -- Any other fields you want from the Activities table
    h.LastComment
    FROM Activities AS a
    LEFT OUTER JOIN History AS h ON a.AccountID = h.AccountID
    WHERE (a.ActivityDate BETWEEN GetDate() AND DateAdd(dd, 240, GetDate()))
    AND h.HistoryID IN (
         SELECT MAX(HistoryID)
         FROM History
         GROUP BY AccountID)
    This method assumes that the History table has a HistoryID that increments up automatically each time a new comment is added... So a comment made today would always have a higher HistoryID that one made yesterday.
    If I'm wrong and there is no HistoryID or the HistoryID doesn't increment in a chronological fashion, it can still be done but the code is a bit more complex.
    HTH,
    Jason

  • Need help with Query

    Hi,
    Good day everyone! I need help writing a query. I have this table with the following data in them...
    ACCT_CODE  FSYR      YTD_AMT
    A123            11          100  
    A456            11          200
    A123            10          50
    A456            10          100I want the output to look like this:
    ACCT_CODE     CURRENT_YEAR(11)       PRIOR_YEAR(10)
    A123               100                              50
    A456               200                              100The user will input the fiscal year and based on that input, I want to get the prior year value as well.
    Thank you for all your help!!
    Edited by: user5737516 on Jun 29, 2011 6:48 AM
    Edited by: user5737516 on Jun 29, 2011 6:50 AM

    user5737516 wrote:
    Hi,
    Good day everyone! I need help writing a query. I have this table with the following data in them...
    ACCT_CODE FSYR YTD_AMT
    A123 11 100
    A456 11 200
    A123 10 50
    A456 10 100
    I want the output to look like this:
    ACCT_CODE CURRENT_YEAR PRIOR_YEAR
    A123 100 50
    A456 200 100
    The user will input the fiscal year and based on that input, I want to get the prior year value as well.
    Thank you for all your help!!what is prior year?

  • Need help with passcode using the "Remote" app

    Hello and thanks in advance. I can't find a place on iTunes to enter the passcode from the Remote app.

    PLEASE READ!!!
    I have a HP Pavilion - Windows XP
    I need help as well with the passcode. I went to Networking and Sharing center and clicked customize and changed the name to NetGear because that is what it says next to my WiFi on my iPhone but with my iPhone under Settings it says WiFi NETGEAR > but when I click on it, it says choose a Network. Is NETGEAR a network? How do I find or change to a Network? is this the problem?

  • Query off of Oracle using WinSql - Need help with query

    I am trying to query off of Oracle using program WinSql.
    I have a table(tticpr200110) that has the following sample data:
    ITEM     CODE     T$AMNT
    23500076 ACL     .0049
    23500076 APM     0
    23500076 APO     .0093
    23500076 EXP     .0001
    23500076 RES     .0072
    and what I want it to look like is:
    ITEM     ACL     APM     APO     EXP     RES
    23500076     0.0049     0     0.0093     0.0001     0.0072
    (actually I need the last 2 columns added together to be MATL-but can deal with that down the road).
    Seems simple enough, but I don't know to put into the columns.
    Any help would be GREATLY appreciated as soon as possible would be even better.

    My table - tticpr200110 when it runs I get the following sample data for part number 23500076:
    The first coloumn ITEM is the part number.
    The second column CODE is 1 of 5 different cost codes
    The third column is the cost for that code for that part.
    ITEM CODE AMNT
    23500076 ACL 0.0049
    23500076 APM 0.0000
    23500076 APO 0.0093
    23500076 EXP 0.0001
    23500076 RES 0.0072
    I want to make a query that makes the data look like this:
    ITEM ACL APM APO EXP RES
    23500076 0.0049 0.0000 0.0093 0.0001 0.0072
    (similar to a pivot table in excel or acess)
    I hope this helps better.
    Thanks!

  • Need help with query that uses 'SELECT INTO'

    Hi guys,
    I am trying to duplicate the values of a table to another by using the script below:
    ACCEPT TBSNAME           CHAR PROMPT 'Tablespace name>'
    PROMPT Connect As System
    Connect system
    CREATE TABLE FREESPACE
         TABLESPACE_NAME          VARCHAR(20)          NOT NULL,
              CONSTRAINT FREESPACE_PKEY PRIMARY KEY(TABLESPACE_NAME),
         TOTAL_FREE_STORAGE     NUMBER(10)          NOT NULL
    ) TABLESPACE USERS;
    SELECT     TABLESPACE_NAME,
              SUM(BLOCKS) TOTBLOCKS
    INTO      FREESPACE
    FROM      SYS.DBA_FREE_SPACE
    WHERE      TABLESPACE_NAME = UPPER('&TBSNAME')
    GROUP BY TABLESPACE_NAME;
    However, when I execute this script, I was prompted with the 'missing keyword' error which happens at the third line of the select statment. Any idea what's missing here?
    Thanks in advance.

    If you mean "fill up the table FREESPACE" by using "select...into..." then it is totally wrong. You cannot do it in plsql also.
    Use this:
    insert into freespace(tablespace_name,total_free_storage)
    SELECT TABLESPACE_NAME,SUM(BLOCKS) TOTBLOCKS
    FROM SYS.DBA_FREE_SPACE
    WHERE TABLESPACE_NAME = UPPER('&TBSNAME')
    GROUP BY TABLESPACE_NAME;
    Message was edited by:
    Yas

  • Need help with query that can look data back please help.

    hi guys i have a table like such
    CREATE TABLE "FGL"
        "FGL_GRNT_CODE" VARCHAR2(60),
        "FGL_FUND_CODE" VARCHAR2(60),
        "FGL_ACCT_CODE" VARCHAR2(60),
        "FGL_ORGN_CODE" VARCHAR2(60),
        "FGL_PROG_CODE" VARCHAR2(60),
        "FGL_GRNT_YEAR" VARCHAR2(60),
        "FGL_PERIOD"    VARCHAR2(60),
        "FGL_BUDGET"    VARCHAR2(60)
      )and i have a data like such
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','1','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','1','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','0');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','14','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','2','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7470','4730','02','10','2','200');I bascially need to get the total of the budget column. however its not as simple as it sound(well atleast not for me.) the totals carry over to the new period. youll noticed the you have a period column. basically what im saying is that
    fgl_grant_year 10 period 1 = for account 7600 its $100 and $100 for period 2 you see 100 dollars again this is not to be added this is the carried over balance. which remains $100.
    so im trying to write a query that basically does the following.
    im given a period for the sake of this example lets say period 1 i get nothing else. I have to find the greates grant year grab the amount for period 14(which is the total from the previous year) and add it to the amount of the current period. in this case period 1 grnt_year 11
    so the expected outcome should be $700
    240055     240055     7240     4730     02     10     14     200
    240055     240055     7600     4730     02     10     14     100
    240055     240055     7600     4730     02     11     1     400keep in mind that im not given a year just a period.
    any help that you guys can offer would be immensely appreciated. I have been trying to get this to work for over 3 days now.
    finally broke down and put together this post
    Edited by: mlov83 on Sep 14, 2011 8:48 PM

    Frank
    wondering if you can help me modify this sql statement that you provided me with .
    table values have been modified a bit.
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','00','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','0');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','1','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('360055','360055','7200','4730','02','10','1','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('360055','360055','7600','4730','02','10','1','400');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','14','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','2','100');
    Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','11','2','600');i need to take one more thing into consideration. if the greatest year has a value on period 00 i need to ignore the period 14 and the current period total would be
    the current period +(current period - greatest year 00)
    hope that makes sense so in other words with the new data above. if i was querying period two of grant year 11. i would end up with $800
    because the greatest year is 11 it contains a period 0 with amount of $400 so my total should be
    period 2 amount $ 600
    period 0 amount $ 400 - period 2 amount of $600 = 200
    600+200 = $800
    if i query period 1 of grant 360055 i would just end up with 800 of grnt year 10.
    i have tried to modify that query you supplied to me with no luck. I have tried for several day but im embarrased to say i just can get it to do what im trying to do .
    can you please help me out.
    Miguel

  • Need help with Query to determine Credit Memos and Invoices

    Hi All
    Thanks for all the help here.
    I need a query to determine any credits or invoices issued within a given period.
    OINV and ORIN with UNION ALL?
    Please advise any help.
    Thank you!

    Hi Daniel,
    Please check below Query.
    SELECT T0.[DocNum] as 'Invice No', T0.[DocDate] as 'Invoice Date', T0.[CardName] as 'Invoiced Customer', T3.[DocNum] as 'Credit Memo No', T3.[DocDate] as 'Credit Mamo Date', T3.[CardName] as 'Credit Memo Customer' FROM OINV T0  LEFT JOIN INV1 T1 ON T0.[DocEntry] = T1.[DocEntry] LEFT JOIN RIN1 T2 ON T2.[BaseEntry] = T1.[DocEntry] AND T2.[BaseLine] =  T1.[LineNum] LEFT JOIN ORIN T3 ON T2.[DocEntry] = T3.[DocEntry] WHERE T0.[DocDate]  >=[%3]  AND   T0.[DocDate] <=[%4]
    Hope this helps
    Regards::::
    Atul Chakraborty

  • Need Help with timing using multiple clips

    I am in need of some help. I am trying to have a total of 16 video clips appear to slide across the screen from the right to the left, all while being equally spaced apart, going the same speed without them crossing over one another. I am using the center and anchor point in the motion tab, but once i get the the third clip i just cant seem to get the time right. I basically want them to come into the screen from the left and out of the screen from the right, all while scrolling acrossed. Please let me know if you have any suggestions.
    I even trued manipulating idvd and imovie themes in Quartz Composer, ended up starting fresh and new, and then again got into the mess with timing. Please help!!!!
    Thanks so much,

    Try this:
    Copy one clip that works OK and use Paste Attributes on the shonky one.
    Al

  • Need help with IQ02 - using a FM do update a value in this transaction

    Hi,
    I am trying to change the Aquisition value (as in transaction  IQ02) using either of following FM:
    ITOB_SERIALNO_MODIFY_SINGLE
    SERIALNUMBER_LIST_UPDATE
    However the changed value of field (ANSWT) is not getting reflected in database.
    I tried ABAP4_COMMIT_WORK, but it didnt work.
    I also tried, BAPI_TRANSACTION_COMMIT but getting a express document message 'Update was terminated.'
    Kindly help me with this. The only thing I need to do is to change the ANSWT (Aquisition value) field.
    Thanks.
    Sanjay
    PS: Help will be rewarded

    It's a bit dangerous to use SAP function modules that are not released to the user to update SAP data because they may not be a complete LUW. IE you may have to run other FMS either before or after. Try to find a BAPI. Maybe BAPI_MATERIAL_MAINTAINDATA_RT is what you need.
    Rob

  • Need help with query from .csv file

    I am trying to import a csv file with only 1 column in it.
    The column will only contain a 9 digit ID number. I want to read
    the file then use the contents to query a table to get the names
    and other information and display it. Here is what I have so far:
    <cffile action="read" file="#form.FiletoUpload#"
    variable="csvfile">
    <cfloop index="index" list="#csvfile#">
    <cfquery name="massimport" datasource="data1">
    SELECT * FROM IDTable
    WHERE CardNumber = ('#csvfile#')
    </cfquery>
    </cfloop>
    <cfoutput>#Name# #ID# #Site#</cfoutput>
    I get no errors but I am not getting any results. Just a
    blank page. Does anyone know how to query directly from a csv
    import? Thanks.

    You need to convert your file to a list somehow. Not sure if
    this is the most efficient way but, you can use the cfhttp tag to
    produce a query. Then your where clause becomes,
    where cardnumber in (#quotedvaluelist(query.column)#)
    and you won't need a loop.

  • Need help with Querying XML - XQuery

    Hey guys, im new to this stuff so  I gained some knowledge from internet but I'm running is some problem that I'll explain below. I have XML like:  
    <?xml version="1.0" encoding="iso-8859-1"?>
    <star:ShowLaborOperations xmlns:star="http://www.starstandard.org/STAR/5" releaseID="5.4.4">
    <star:ApplicationArea>
    <star:Sender>
    <star:CreatorNameCode>AD</star:CreatorNameCode>
    <star:SenderNameCode>DDDD</star:SenderNameCode>
    <star:SystemVersion>AD2.0</star:SystemVersion>
    </star:Sender>
    <star:CreationDateTime>2011-05-06T12:51:33Z</star:CreationDateTime>
    <star:BODID>A29BF24F-F68E-5CE5-E040-35A54242A0C</star:BODID>
    <star:Destination>
    <star:DestinationNameCode>AD</star:DestinationNameCode>
    </star:Destination>
    </star:ApplicationArea>
    <star:ShowLaborOperationsDataArea>
    <star:Show>
    <oagis:ResponseCriteria xmlns:oagis="http://www.openapplications.org/oagis/9">
    <oagis:ChangeStatus>
    <oagis:Description>Changes</oagis:Description>
    </oagis:ChangeStatus>
    </oagis:ResponseCriteria>
    </star:Show>
    <star:LaborOperations>
    <star:LaborOperationsHeader>
    <star:RequestCode>Changes</star:RequestCode>
    <star:LaborOperationsHeaderBase>
    <star:DocumentIdentificationGroup>
    <star:DocumentIdentification>
    <star:DocumentID>ShowOperationCode20110506050532TY</star:DocumentID>
    </star:DocumentIdentification>
    </star:DocumentIdentificationGroup>
    </star:LaborOperationsHeaderBase>
    <star:LaborOperationCodes/>
    </star:LaborOperationsHeader>
    <star:LaborOperationsDetail>
    <star:LaborOperationID>001020</star:LaborOperationID>
    <star:MajorGroupID>00</star:MajorGroupID>
    <star:ComponentGroupID>01</star:ComponentGroupID>
    <star:LaborOperationDescription>GAS TANK FILL</star:LaborOperationDescription>
    <star:LaborActionCode>OTH</star:LaborActionCode>
    <star:LaborOperationsChangeStatus>U</star:LaborOperationsChangeStatus>
    <star:Combinations>
    <star:VehicleGroupLaborAllowance>
    <star:VehicleIdentificationGroup>
    <star:VehicleGroupID>JTN</star:VehicleGroupID>
    <star:VehicleID>JJXB0</star:VehicleID>
    </star:VehicleIdentificationGroup>
    <star:ChangeStatus>A</star:ChangeStatus>
    <star:LaborAllowanceMeasure unitCode="hour">0.0</star:LaborAllowanceMeasure>
    <star:ChargeHoursIndicator>false</star:ChargeHoursIndicator>
    </star:VehicleGroupLaborAllowance>
    <star:VehicleGroupLaborAllowance>
    <star:VehicleIdentificationGroup>
    <star:VehicleGroupID>JTM</star:VehicleGroupID>
    <star:VehicleID>ZF32V</star:VehicleID>
    </star:VehicleIdentificationGroup>
    <star:ChangeStatus>U</star:ChangeStatus>
    <star:LaborAllowanceMeasure unitCode="hour">0.6</star:LaborAllowanceMeasure>
    <star:ChargeHoursIndicator>true</star:ChargeHoursIndicator>
    </star:VehicleGroupLaborAllowance>
    </star:Combinations>
    </star:LaborOperationsDetail>
    </star:LaborOperations>
    </star:ShowLaborOperationsDataArea>
    </star:ShowLaborOperations>
    and I wanna be able to see the following result: 
    <LaborOperationsDetail xmlns="http://www.starstandard.org/STAR/5">
    <LaborOperationID>001020</LaborOperationID>
    <MajorGroupID>00</MajorGroupID>
    <ComponentGroupID>01</ComponentGroupID>
    <LaborOperationDescription>GAS TANK FILL</LaborOperationDescription>
    <LaborActionCode>OTH</LaborActionCode>
    <LaborOperationsChangeStatus>U</LaborOperationsChangeStatus>
    <Combinations>
    <VehicleGroupLaborAllowance>
    <VehicleIdentificationGroup>
    <VehicleGroupID>JTN</VehicleGroupID>
    <VehicleID>JJXB0</VehicleID>
    </VehicleIdentificationGroup>
    <ChangeStatus>A</ChangeStatus>
    <LaborAllowanceMeasure unitCode="hour">0.0</LaborAllowanceMeasure>
    <ChargeHoursIndicator>false</ChargeHoursIndicator>
    </VehicleGroupLaborAllowance>
    </Combinations>
    </LaborOperationsDetail>
    for which I'm writing the following query 
    SELECT OpCodeXMLCol.query('
    declare default element namespace "http://www.starstandard.org/STAR/5";
    /ShowLaborOperations/ShowLaborOperationsDataArea/LaborOperations/LaborOperationsDetail[Combinations/VehicleGroupLaborAllowance/VehicleIdentificationGroup/VehicleGroupID="JTN"][LaborOperationID="001020"]
    -- specified [LaborOperationID="001020"] because there are multiple <LabrOperationDetial> ') as x
    FROM XMLData.dbo.OpCodeData
    where [ID] = 3 -- primary key for that row containing XML in first snippet
    but I'm getting both nodes for <VehicleIdentificatonGroup> whereas I expect to see one containing <VehicleGroupID>JTN</VehicleGroupID> as per filter in query. Please help

    The closest thing which makes sense:
    DECLARE @Data XML = N'
    <star:ShowLaborOperations xmlns:star="http://www.starstandard.org/STAR/5" releaseID="5.4.4">
    <star:ApplicationArea>
    <star:Sender>
    <star:CreatorNameCode>AD</star:CreatorNameCode>
    <star:SenderNameCode>DDDD</star:SenderNameCode>
    <star:SystemVersion>AD2.0</star:SystemVersion>
    </star:Sender>
    <star:CreationDateTime>2011-05-06T12:51:33Z</star:CreationDateTime>
    <star:BODID>A29BF24F-F68E-5CE5-E040-35A54242A0C</star:BODID>
    <star:Destination>
    <star:DestinationNameCode>AD</star:DestinationNameCode>
    </star:Destination>
    </star:ApplicationArea>
    <star:ShowLaborOperationsDataArea>
    <star:Show>
    <oagis:ResponseCriteria xmlns:oagis="http://www.openapplications.org/oagis/9">
    <oagis:ChangeStatus>
    <oagis:Description>Changes</oagis:Description>
    </oagis:ChangeStatus>
    </oagis:ResponseCriteria>
    </star:Show>
    <star:LaborOperations>
    <star:LaborOperationsHeader>
    <star:RequestCode>Changes</star:RequestCode>
    <star:LaborOperationsHeaderBase>
    <star:DocumentIdentificationGroup>
    <star:DocumentIdentification>
    <star:DocumentID>ShowOperationCode20110506050532TY</star:DocumentID>
    </star:DocumentIdentification>
    </star:DocumentIdentificationGroup>
    </star:LaborOperationsHeaderBase>
    <star:LaborOperationCodes/>
    </star:LaborOperationsHeader>
    <star:LaborOperationsDetail>
    <star:LaborOperationID>001020</star:LaborOperationID>
    <star:MajorGroupID>00</star:MajorGroupID>
    <star:ComponentGroupID>01</star:ComponentGroupID>
    <star:LaborOperationDescription>GAS TANK FILL</star:LaborOperationDescription>
    <star:LaborActionCode>OTH</star:LaborActionCode>
    <star:LaborOperationsChangeStatus>U</star:LaborOperationsChangeStatus>
    <star:Combinations>
    <star:VehicleGroupLaborAllowance>
    <star:VehicleIdentificationGroup>
    <star:VehicleGroupID>JTN</star:VehicleGroupID>
    <star:VehicleID>JJXB0</star:VehicleID>
    </star:VehicleIdentificationGroup>
    <star:ChangeStatus>A</star:ChangeStatus>
    <star:LaborAllowanceMeasure unitCode="hour">0.0</star:LaborAllowanceMeasure>
    <star:ChargeHoursIndicator>false</star:ChargeHoursIndicator>
    </star:VehicleGroupLaborAllowance>
    <star:VehicleGroupLaborAllowance>
    <star:VehicleIdentificationGroup>
    <star:VehicleGroupID>JTM</star:VehicleGroupID>
    <star:VehicleID>ZF32V</star:VehicleID>
    </star:VehicleIdentificationGroup>
    <star:ChangeStatus>U</star:ChangeStatus>
    <star:LaborAllowanceMeasure unitCode="hour">0.6</star:LaborAllowanceMeasure>
    <star:ChargeHoursIndicator>true</star:ChargeHoursIndicator>
    </star:VehicleGroupLaborAllowance>
    </star:Combinations>
    </star:LaborOperationsDetail>
    </star:LaborOperations>
    </star:ShowLaborOperationsDataArea>
    </star:ShowLaborOperations>
    WITH XMLNAMESPACES ( DEFAULT 'http://www.starstandard.org/STAR/5' )
    SELECT LaborOperationsDetail.query('.'),
    VehicleGroupLaborAllowance.query('.')
    FROM @Data.nodes('/ShowLaborOperations/ShowLaborOperationsDataArea/LaborOperations/LaborOperationsDetail') A ( LaborOperationsDetail )
    CROSS APPLY LaborOperationsDetail.nodes('Combinations/VehicleGroupLaborAllowance[VehicleIdentificationGroup/VehicleGroupID="JTN"]') B ( VehicleGroupLaborAllowance );
    Otherwise we need to destruct and rebuild the XML. This in this case imho better done with XSLT.

  • Need help with query for converting columns to rows

    Hello,
    I know this is a very common question asked in the forum. I have searched regading this, i did find some threads, but i was not able to achieve what i require from the answers posted. So anybody please help me.
    I have a table which is having multiple columns as follows:
    Insert into table_1 (X,Y,Z,A,B,C,D,E,F,G,H,I) values (0,0,2,0,0,1,3,0,0,0,0,0);I want to convert the result into a two column, multiple rows i.e., I want the result as follows:
    Col1 Col2
    X      0
    Y     0
    Z      2
    A     0
    B     0
    C     1
    D     3
    E     0
    F     0
    G     0
    H     0
    I      0Please anybody help me in writing the query for this..

    Is this what you are expecting:
    SQL> WITH T AS
      2  (
      3  SELECT 0 X, 0 Y, 2 Z, 0 A, 0 B, 1 C, 3 D, 0 E, 0 F, 0 G, 0 H, 0 I FROM DUAL
      4  )
      5  SELECT  'X' col1, X col2 FROM T
      6  UNION ALL
      7  SELECT  'Y' col1, Y col2 FROM T
      8  UNION ALL
      9  SELECT  'Z' col1, Z col2 FROM T
    10  UNION ALL
    11  SELECT  'A' col1, A col2 FROM T
    12  UNION ALL
    13  SELECT  'B' col1, B col2 FROM T
    14  UNION ALL
    15  SELECT  'C' col1, C col2 FROM T
    16  UNION ALL
    17  SELECT  'D' col1, D col2 FROM T
    18  UNION ALL
    19  SELECT  'E' col1, E col2 FROM T
    20  UNION ALL
    21  SELECT  'F' col1, F col2 FROM T
    22  UNION ALL
    23  SELECT  'G' col1, G col2 FROM T
    24  UNION ALL
    25  SELECT  'H' col1, H col2 FROM T
    26  UNION ALL
    27  SELECT  'I' col1, I col2 FROM T
    28  /
    C       COL2                                                                   
    X          0                                                                   
    Y          0                                                                   
    Z          2                                                                   
    A          0                                                                   
    B          0                                                                   
    C          1                                                                   
    D          3                                                                   
    E          0                                                                   
    F          0                                                                   
    G          0                                                                   
    H          0                                                                   
    C       COL2                                                                   
    I          0                                                                   
    12 rows selected.

Maybe you are looking for

  • Restriction on number of invoices to be paid through APP for each vendor

    Hi, We configured APP and print cheques through APP. The output contains invoice wise details ( Payment advice) and the cheque. In case the Number of invoices are more than 10 for a single vendor, it is printing one cheque -- This is OK. But the prob

  • Workflow Question: Audio Documentaries

    Hello there, I am trying to figure out the most efficient workflow for 2 types of audio pieces that will end up in a podcast: 1) The first type is one long interview (an hr) that will be extensively edited (e.g., sentences and words rearranged; "ums"

  • WRV210 loses port forwarding settings after reboot

    Along with wireless problems that have already been documented about this device I am having problems with port forwarding where it will lose all its settings after losing its power.  I then try to go into the management for port forwarding and am no

  • Nokia Connectivity Cable driver problem (Nokia 311...

    I have an unlocked Nokia 3110 Classic with 2 GB MicroSD Nokia MU-37 memory card. On my PC operating system is Windows XP Service Pack 3. For connection with PC I use an original Nokia DKE-2 USB 2.0 data cable. My problem is when I install any version

  • COST center Discription  table name please

    Hi All We knew CSKS is  acost center table what is the description of cost center name table 1234  is a cost center and its description is Maintanance center  where i can see this "Maintanance center" - description of cost center. Muthu