Problem selecting MAX YEAR MAX MONTH MAX DATE in one query

CREATE TABLE TEMP
C_INVOICE_ID NUMBER(10),
DIA NUMBER,
MES NUMBER,
ANO NUMBER,
SOCIO_NEGOCIO NVARCHAR2(60) NOT NULL,
PRODUCTO_NOM NVARCHAR2(60) NOT NULL,
M_PRODUCT_ID NUMBER(10),
CATEGORIA NVARCHAR2(60) NOT NULL,
COSTO NUMBER
INSERT INTO TEMP VALUES(10111,1,2,2010,'1585','ALURON 100MG X 30 TABLETAS',1530,15,1.15);
INSERT INTO TEMP VALUES(1015,15,2,2010,'1520','ALURON 100MG X 30 TABLETAS',1530,15,2.15);
INSERT INTO TEMP VALUES(5654,5,2,2010,'1520','AMARYL 2MG X 15 TABLETAS',1531,15,4.2);
INSERT INTO TEMP VALUES(15321,4,6,2010,'1520','AMARYL 2MG X 15 TABLETAS',1531,15,4.8);
INSERT INTO TEMP VALUES(13548,8,6,2010,'1585','AMARYL 2MG X 15 TABLETAS',1531,15,4.3);
INSERT INTO TEMP VALUES(19456,31,4,2010,'1220','AMARYL 2MG X 15 TABLETAS',1531,15,4);
INSERT INTO TEMP VALUES(116544,8,8,2010,'1220','AMARYL 2MG X 15 TABLETAS',1531,15,4.8);
INSERT INTO TEMP VALUES(132,2,3,2010,'1220','AMARYL 2MG X 15 TABLETAS',1531,15,4.1);
INSERT INTO TEMP VALUES(168,15,1,2010,'1220','AMARYL 2MG X 15 TABLETAS',1531,15,4.9);
INSERT INTO TEMP VALUES(4898,7,4,2010,'1220','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.8);
INSERT INTO TEMP VALUES(15132,25,9,2010,'1585','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.4);
INSERT INTO TEMP VALUES(1684,18,8,2010,'1585','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.3);
INSERT INTO TEMP VALUES(14988,8,8,2010,'1585','AMOXAL 250MG X 75ML SUSPENSION',1534,15,2.9);
INSERT INTO TEMP VALUES(84941,8,9,2010,'1585','AMOXAL 250MG X 75ML SUSPENSION',1534,15,4.1);
INSERT INTO TEMP VALUES(1155,7,4,2010,'1585','AMOXAL 250MG X 75ML SUSPENSION',1534,15,4.7);
INSERT INTO TEMP VALUES(184,1,1,2010,'1520','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.9);
INSERT INTO TEMP VALUES(48994,8,4,2010,'1520','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.7);
INSERT INTO TEMP VALUES(1465465,9,5,2009,'1520','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.8);
INSERT INTO TEMP VALUES(16,18,6,2009,'1520','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.9);
INSERT INTO TEMP VALUES(894886,20,4,2009,'1520','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.9);
CREATE TABLE TEMP
C_INVOICE_ID NUMBER(10),
DIA NUMBER,
MES NUMBER,
ANO NUMBER,
SOCIO_NEGOCIO NVARCHAR2(60) NOT NULL,
PRODUCTO_NOM NVARCHAR2(60) NOT NULL,
M_PRODUCT_ID NUMBER(10),
CATEGORIA NVARCHAR2(60) NOT NULL,
COSTO NUMBER
INSERT INTO TEMP VALUES(10111,1,2,2010,'1585','ALURON 100MG X 30 TABLETAS',1530,15,1.15);
INSERT INTO TEMP VALUES(1015,15,2,2010,'1520','ALURON 100MG X 30 TABLETAS',1530,15,2.15);
INSERT INTO TEMP VALUES(5654,5,2,2010,'1520','AMARYL 2MG X 15 TABLETAS',1531,15,4.2);
INSERT INTO TEMP VALUES(15321,4,6,2010,'1520','AMARYL 2MG X 15 TABLETAS',1531,15,4.8);
INSERT INTO TEMP VALUES(13548,8,6,2010,'1585','AMARYL 2MG X 15 TABLETAS',1531,15,4.3);
INSERT INTO TEMP VALUES(19456,31,4,2010,'1220','AMARYL 2MG X 15 TABLETAS',1531,15,4);
INSERT INTO TEMP VALUES(116544,8,8,2010,'1220','AMARYL 2MG X 15 TABLETAS',1531,15,4.8);
INSERT INTO TEMP VALUES(132,2,3,2010,'1220','AMARYL 2MG X 15 TABLETAS',1531,15,4.1);
INSERT INTO TEMP VALUES(168,15,1,2010,'1220','AMARYL 2MG X 15 TABLETAS',1531,15,4.9);
INSERT INTO TEMP VALUES(4898,7,4,2010,'1220','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.8);
INSERT INTO TEMP VALUES(15132,25,9,2010,'1585','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.4);
INSERT INTO TEMP VALUES(1684,18,8,2010,'1585','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.3);
INSERT INTO TEMP VALUES(14988,8,8,2010,'1585','AMOXAL 250MG X 75ML SUSPENSION',1534,15,2.9);
INSERT INTO TEMP VALUES(84941,8,9,2010,'1585','AMOXAL 250MG X 75ML SUSPENSION',1534,15,4.1);
INSERT INTO TEMP VALUES(1155,7,4,2010,'1585','AMOXAL 250MG X 75ML SUSPENSION',1534,15,4.7);
INSERT INTO TEMP VALUES(184,1,1,2010,'1520','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.9);
INSERT INTO TEMP VALUES(48994,8,4,2010,'1520','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.7);
INSERT INTO TEMP VALUES(1465465,9,5,2009,'1520','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.8);
INSERT INTO TEMP VALUES(16,18,6,2009,'1520','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.9);
INSERT INTO TEMP VALUES(894886,20,4,2009,'1520','AMOXAL 250MG X 75ML SUSPENSION',1534,15,3.9);
I have this query so far,
SELECT
MAX (TEMP.COSTO) COSTO,
TEMP.M_PRODUCT_ID,
TEMP.ANO
FROM TEMP TEMP
INNER JOIN(
SELECT MAX(ANO) ANO, M_PRODUCT_ID
FROM TEMP I
GROUP BY M_PRODUCT_ID
) LA ON LA.ANO = TEMP.ANO AND LA.M_PRODUCT_ID = TEMP.M_PRODUCT_ID
GROUP BY
TEMP.M_PRODUCT_ID,
TEMP.ANO
but my intention is not to have the max cost, my intention is to query in this order
first i need to select distinct m_product_id then
for every m_product_id i need to
filter max (ano) then filter max (mes) then filter max (dia)
I need the result set like this.
C_INVOICE_ID DIA MES ANO SOCIO PRODUCTO_NOM M_PRODUCT_ID CATERGORIA COSTO
1015 15 2 2010 1520 ALURON 100MG X 30 TABLETAS 1530 15 2.15
5654 5 2 2010 1520 AMARYL 2MG X 15 TABLETAS 1531 15 4.2
15132 25 9 2010 1585 AMOXAL 250MG X 75ML SUSPENSION 1534 15 3.4
please i really apritiated any help, thanks pd:i'm using oracle 9i

Hi,
Thanks for posting the CREATE TABLE and INSERT statements. Why are there two tables, and two sets of data? Was that a mistake?
Sorry, I don't uderstand the problem.
For m_product_id=1531, for example, why do you want
INSERT INTO TEMP VALUES(5654,     5, 2, 2010,'1520','AMARYL 2MG X 15 TABLETAS',1531,15,4.2);selected, and not
INSERT INTO TEMP VALUES(116544,     8, 8, 2010,'1220','AMARYL 2MG X 15 TABLETAS',1531,15,4.8);Both rows have ano=2010, so don't you want the one with the higher mes (8 > 2)?
I think what you'll want is a Top-N Query , something like this:
WITH     got_r_num     AS
     SELECT     temp.*     -- or list columns you want
     ,     RANK () OVER ( PARTITION BY  m_product_id
                      ORDER BY          ano     DESC     NULLS FIRST
                      ,          mes     DESC     NULLS FIRST
                      ,          dia     DESC     NULLS FIRST
                    )          AS r_num
     FROM     temp
--     WHERE     ...     -- any filtering goes here
SELECT     *     -- or list all columns except r_num
FROM     got_r_num
WHERE     r_num     = 1
;What if there's a tie? For example, if you add another row to the sample data:
INSERT INTO TEMP VALUES(9876,     15,2, 2010,'1520','ALURON 100MG X 30 TABLETAS',1530,15,2.15);The query above would include both c_invoice_id=9876 and 1015. If you want just one of those rows, add more expressions to the analytic ORDER BY clause and/or use ROW_NUMBER instead of RANK.

Similar Messages

  • Select records based on monthly anniversary date

    Hi,
    I have a table with a date_added field and I want to select records based on the monthly anniversary date of this field.
    eg. ID, Date_added
    1, 10-DEC-2012
    2, 11-NOV-2012
    3, 10-MAR-2012
    4, 28-FEB-2012
    5, 30-DEC-2012
    So For the 10th of Jan 2013, I would want to return records 1 and 3 only
    I started looking at the extract function, but this soon falls down for records at the end of the month. For example, on the 28th Feb, I would also want to include records where the date_added day is the 29th, 30th or 31st. So, in the table above I would want to return records 4 and 5, but extract would only return 4.
    Is there a simple function to do this month anniversary query - am I missing something very obvious? Or, do I need to write a query to explicitly cope with dates at the end of the month? So far I haven't found a sensible simple solution!
    I'm using 11g
    thanks

    I didn't look into leap year, but this should give you a starting point:
    select  *
      from  t
      where 1 = case last_day(to_date(:target_date,'mmddyyyy'))
                  when to_date(:target_date,'mmddyyyy')
                    then case
                           when to_char(date_added,'dd') >= to_char(to_date(:target_date,'mmddyyyy'),'dd')
                             then 1
                         end
                  else case
                           when to_char(date_added,'dd') = to_char(to_date(:target_date,'mmddyyyy'),'dd')
                             then 1
                         end
                end
    /For example, target date is 1/10/2013:
    SQL> variable target_date varchar2(8)
    SQL> exec :target_date := '01102013';
    PL/SQL procedure successfully completed.
    SQL> with t as (
      2             select 1 id,to_date('10-DEC-2012','dd-mon-yyyy') date_added from dual union all
      3             select 2,to_date('11-NOV-2012','dd-mon-yyyy') from dual union all
      4             select 3,to_date('10-MAR-2012','dd-mon-yyyy') from dual union all
      5             select 4,to_date('28-FEB-2012','dd-mon-yyyy') from dual union all
      6             select 5,to_date('30-DEC-2012','dd-mon-yyyy') from dual
      7            )
      8  select  *
      9    from  t
    10    where 1 = case last_day(to_date(:target_date,'mmddyyyy'))
    11                when to_date(:target_date,'mmddyyyy')
    12                  then case
    13                         when to_char(date_added,'dd') >= to_char(to_date(:target_date,'mmddyyyy'),'dd')
    14                           then 1
    15                       end
    16                else case
    17                         when to_char(date_added,'dd') = to_char(to_date(:target_date,'mmddyyyy'),'dd')
    18                           then 1
    19                       end
    20              end
    21  /
            ID DATE_ADDE
             1 10-DEC-12
             3 10-MAR-12
    SQL> And target date is 2/28/2013:
    SQL> exec :target_date := '02282013';
    PL/SQL procedure successfully completed.
    SQL> with t as (
      2             select 1 id,to_date('10-DEC-2012','dd-mon-yyyy') date_added from dual union all
      3             select 2,to_date('11-NOV-2012','dd-mon-yyyy') from dual union all
      4             select 3,to_date('10-MAR-2012','dd-mon-yyyy') from dual union all
      5             select 4,to_date('28-FEB-2012','dd-mon-yyyy') from dual union all
      6             select 5,to_date('30-DEC-2012','dd-mon-yyyy') from dual
      7            )
      8  select  *
      9    from  t
    10    where 1 = case last_day(to_date(:target_date,'mmddyyyy'))
    11                when to_date(:target_date,'mmddyyyy')
    12                  then case
    13                         when to_char(date_added,'dd') >= to_char(to_date(:target_date,'mmddyyyy'),'dd')
    14                           then 1
    15                       end
    16                else case
    17                         when to_char(date_added,'dd') = to_char(to_date(:target_date,'mmddyyyy'),'dd')
    18                           then 1
    19                       end
    20              end
    21  /
            ID DATE_ADDE
             4 28-FEB-12
             5 30-DEC-12
    SQL> SY.

  • Selective deletion of 3 month back data in Process chain

    Hello,
    I have one dso which should contain only 3 month of data.
    If i load current month dat it should delete three months back data for eg if i load data for april month then it should delete january month data. I want to do this step in process chain.
    How can i do it plz help me.
    regards,
    Naveen

    Hello Naveen
    If the DSO is of type Write Optimized, then you could use the following option in the process chain.
    1. Include the Step ABAP program ( General services) into the process chain.
    2. Enter standard program: RSSM_DELETE_WO_DSO_REQUESTS. Click on Create button for the variant and enter the following details: Enter the name of the WODSO name, Check the box for Delete Requests, Enter the number of days ( in this case 30) for deletion, Check the box if the Requests are delta updated on the WO DSO. Find the snapshot attached.
    Also, remember that PSA data should be deleted regularly (30 days in this case). This step should be inlcuded as the first step in the housekeeping activity.
    Thanks and Regards,
    Ningaraju

  • Picking Month from Date in ABAP query

    Dear All,
    I want to pick month from date in a abap query but it is giving error "BDTER" is not a valid comparison operator. comparison operator.
    Where i am wrong my query is below.
    SELECT SUM( BDMNG ) AS BDMNGT FROM RESB INTO CORRESPONDING FIELDS OF IT_MRP
    WHERE MONTH( BDTER ) = '12'.
    With Regards
    Ashwani K Mathur

    Dear Deepankar,
    Thanks for reply.
    Date fomat is yy/mm/dd (like 20071231) after your suggestion i have modified query.
    SELECT SUM( BDMNG ) AS BDMNGT FROM RESB INTO CORRESPONDING FIELDS OF IT_MRP
    WHERE  BDTER+4(2)  = 12.
    but while compiling it is giving error Field "BDTER+4(2)" unknown.
    Please suggest.
    Ashwani K Maathur

  • Retrieving spatial and non spatial data in one query

    Hello. I am having slight difficulties using JDBC to retrieve both spatial and non spatial data in the same query. The following is code from a sample program of mine that retrives spatial data from spatial tables.
    (In spatialquery geom is a geometry column and city is simply the name of the city):
    try
    Geometry geom = null;
    String database = "jdbc:oracle:thin:@" + m_host + ":" + m_port + ":" + m_sid;
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = (OracleConnection)DriverManager.getConnection(database, sUsername, sPassword);
    GeometryAdapter sdoAdapter =
    OraSpatialManager.getGeometryAdapter("SDO", "8.1.7", STRUCT.class, null, null, con);
    String spatialquery = "SELECT a1.geom, a1.city \n" +
    "FROM cities a1";
    Statement stmt = con.createStatement();
    OracleResultSet rs = (OracleResultSet) stmt.executeQuery(spatialquery);
    int i = 0;
    int noOfFeatures = 2;
    while (rs.next())
    for(i = 1; i <= noOfFeatures; i++)
    STRUCT dbObject = (STRUCT)rs.getObject(i);
    try
    geom = sdoAdapter.importGeometry(dbObject);
    catch(GeometryInputTypeNotSupportedException e)
    System.out.println("Input Type not supported");
    catch(InvalidGeometryException e)
    System.out.println("Invalid geometry");
    System.out.println(geom);
    }//end while loop
    This retrieves the sptial data fine, however when I attempt to retreive the non-spatial data I keep getting a "ClassCastException" error. I understand it is something to do with "STRUCT dbObject = (STRUCT)rs.getObject(i);" line. Can anyone tell me how to retrieve both spatial and non-spatial data in the one query using JDBC. I have tried nearly everything at this stage. Cheers joe

    Theresa A Radke
    Posts: 20
    OTN Member Since: Jul, 2001
    retrieving spatial and non spatial in same query. May 23, 2003 12:02 AM
    retrieving spatial and non spatial in same query.

  • Using the EXTRACT function to get year and month from date

    Hello~
    I am trying to extract the month and year using the query below but am getting the error:
    Query cannot be parsed within the Builder
    select     distinct city AS "CITY",count(MOTOR_ASSIST2.CITY) as "COUNT"
    from     "MOTOR_ASSIST2" "MOTOR_ASSIST2"
    where
    (:P53_FISCAL_YR IS NULL OR :P53_FISCAL_YR = MOTOR_ASSIST2.FY)
    *OR (:P53_MONTH IS NULL OR EXTRACT(MONTH FROM :P53_MONTH) = MOTOR_ASSIST2.DATETIME)
    OR (:P53_YEAR IS NULL OR EXTRACT(YEAR FROM :P53_YEAR) = MOTOR_ASSIST2.DATETIME))*
    GROUP BY MOTOR_ASSIST2.CITY
    ORDER BY CITY
    Can anyone help me figure out what im doing wrong?Thanks
    Deanna

    1. Whats the value of year you are passing here ??
    2. Whats the value of months you are passing here??
    Select City As "CITY", Count(Motor_Assist2.City) As "COUNT"
      From "MOTOR_ASSIST2" "MOTOR_ASSIST2"
    Where ((:P53_Fiscal_Yr Is Null Or :P53_Fiscal_Yr = Motor_Assist2.Fy) Or
           (:P53_Month Is Not Null Or :P53_Month = Motor_Assist2.Month) And
           (:P53_Year Is Not Null Or :P53_Year = Motor_Assist2.Year) And
           Datetime >= To_Date(:P53_Year||:P53_Month, 'YYYYMON') And
           Datetime > Add_Months(To_Date(:P53_Year||:P53_Month, 'YYYYMON'), 1)
    Group By Motor_Assist2.City
    Order By City
    SQL> Select Sysdate From dual Where Sysdate = To_Date('2008'||'SEP', 'YYYYMON');
    SYSDATE
    Select Sysdate From dual Where Sysdate = To_Date('2008'||'SEP', 'YYYYMON');
    SYSDATE
    SQL> Select To_Date('2008'||'SEP', 'YYYYMON') From dual;
    TO_DATE('2008'||'SEP','YYYYMON
    9/1/2008
    will give you sept 1st or 1st day of the month,
    hows the data in your datetime column or variable ???
    SQL> Select Sysdate From dual Where trunc(add_months(last_day(Sysdate),-1) +1) = To_Date('2008'||'SEP', 'YYYYMON');
    SYSDATE
    9/12/2008 3
    SQL>
    there both side of '=' yield first day of sept ...
    SQL>

  • CAML Query to get Items based on Year and Month From Date Column

    Hi All,
           * As we knew that there are default columns in calendar like Stattdate,Title,Location..etc.
            * I required the CAML Query to get the list items of calender of particular Month and Year,So that I can get number of items or evetns are in Calendar
    Can any one help me how can I do this using caml query
    Samar

    Hi Stuart,
                 Thanks for your response,I had chosen 2nd option of our above mention suggestion.But when I try to fetech the data from a calendar it is showing below error .I
    had checked the below code with oter lists by changing Type to text and it worked fine.Can you please help me how can I fetech for the calulated columns
    Error
    "One or more field
    types are not installed properly. Go to the list settings page to delete these
    fields. "
    Code:
     string year="2014";
                string month="February";
                SPSite mysite = SPContext.Current.Site;
                SPWeb myweb = mysite.OpenWeb();
                try
                    SPList mylist = myweb.Lists["Calendar"];
                    SPQuery myquery = new SPQuery();
                    myquery.Query = @"<Where>
                                          <And>
                                           <Eq>
                                             <FieldRef Name='Year'/>
                                             <Value Type='Calculated'>"
    + year + @"</Value>
                                          </Eq>
                                          <Eq>
                                             <FieldRef Name='Month'
    />
                                             <Value Type='Calculated'>"
    + month + @"</Value>
                                          </Eq>
                                         </And>
                                      </Where>";
                    SPListItemCollection totaltiems = mylist.GetItems(myquery);
                   Label1.Text= "Total Number of Items is "+" "+totaltiems.Count.ToString();
                catch (Exception ee)
                    Label1.Text = ee.Message;
                finally
                    myweb.Dispose();
    Calculated Columns
    Samar

  • How to select data in one query ?

    I have a table "My_Table" with the data like below -
    order_seq      |ONE_CODE      |TWO_CODE     | ONE_VAL     | TWO_VAL
    1          |ABC          |DDD          |1100          |1900
    2          |PQR          |TTT          |5000          |3000
    3          |PQR          |JJJ          |5000          |2000
    4          |DEF          |CCC          |500          |4500
    5          |LMN          |CCC          |4000          |4500
    6          |ABC          |CCC          |1100          |4500I want to add 3 more columns along with modifying the ONE_VAL and TWO_VAL columns, which will show the resultset like below -
    ONE_REMINDER will show value 0 if TWO_VAL < ONE_VAL otherwise will show (ONE_VAL - TWO_VAL)
    TWO_REMINDER will show value 0 if TWO_VAL > ONE_VAL otherwise will show ABS(ONE_VAL - TWO_VAL)
    ONE_VAL will show value lag(ONE_REMINDER) order by ONE_CODE, order_seq
    TWO_VAL will show value lag(TWO_REMINDER) order by TWO_CODE, order_seq
    LEAST column will show the least value in between ONE_VAL and TWO_VAL
    order_seq      |ONE_CODE      |TWO_CODE     | ONE_VAL     | TWO_VAL      |LEAST     |ONE_REMINDER |     TWO_REMINDER
    1          |ABC          |DDD          |1100          |1900          |1100          |0          |800
    2          |PQR          |TTT          |5000          |3000          |3000          |2000          |0
    3          |PQR          |JJJ          |5000          |2000          |2000          |0          |0
    4          |DEF          |CCC          |500          |4600          |500          |0          |4100
    5          |LMN          |CCC          |4000          |4100          |4000          |0          |100
    6          |ABC          |CCC          |0          |100          |0          |0          |100Can someone please help ?
    Edited by: userP5 on Jul 19, 2010 7:08 PM

    Not tested, don't have your tables and don't feel like constructing them based on your sample data :)
    SELECT
       order_seq,
       one_code,
       two_code,
       ONE_REMINDER,
       TWO_REMINDER,
       lag(one_reminder) over (order by one_code, order_seq) AS ONE_VAL,
       lag(two_reminder) over (order by one_code, order_seq) AS TWO_VAL,
       LEAST_VAL
    FROM
       SELECT
          order_seq,
          one_code,
          two_code,
          CASE WHEN TWO_VAL < ONE_VAL THEN 0 ELSE ONE_VAL - TWO_VAL END        AS ONE_REMINDER,
          CASE WHEN TWO_VAL > ONE_VAL THEN 0 ELSE ABS(ONE_VAL - TWO_VAL) END   AS TWO_REMINDER,
          LEAST(ONE_VAL, TWO_VAL)                                              AS LEAST_VAL
       FROM
          SOME_MYTHICAL_TABLE
    );Would be the basic idea, adapt as needed.

  • URGENT: How to selectively migrate composite instances and task data from one env to another

    Gurus,
    We've come across a situation whereby we need to migrate instance data (including Human Task related) of some specific composites from one environment to another.
    (Environment is equivalent here to a different domain installation on different physical server.)
    Is this possible in some standard way like using Oracle import-export utility or script?
    If not, how can this be achieved?
    Thanks in advance for any help you can provide on this.
    With regards-
    Ashish

    Hi,
    If your SharePoint environment supports InfoPath Forms, then you can customize the form and add rules to make the list items as read only when user A submits the form.
    you can then write a form load event to check the logged in user using username() function. This logic can be implemented in variety of ways, like setting a flag when User A submits the form, or storing user A username in a form variable etc., else comparing
    User A and User B values within form Load event.
    Another way of doing this is using Views or grouping all of the User A fields within a section etc.,
    The above would take care of Form logic, and for the workflow, you can use SharePoint designer to create a custom workflow, where it will run on onItemCreate and onItemChange events.
    The logic for workflow would be if the form Submitted for the first time, the workflow will start and send an email to User B, and when User B submits the Data then onItemChange change event will start the workflow to send an email to approver to approve
    the data.
    here are some links for your reference -
    http://office.microsoft.com/en-us/infopath-help/add-formulas-and-functions-in-infopath-2010-HA101821255.aspx
    http://office.microsoft.com/en-us/videos/video-create-an-approval-workflow-in-sharepoint-designer-2010-VA101897477.aspx
    http://blogs.technet.com/b/meacoex/archive/2010/11/01/get-manager-approval-in-sharepoint-designer-2010-step-by-step.aspx
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • How to show the data of one query since Forms9i using to Report built-in on

    Hello!!!, I have Developer 9i (Forms and Reports), the OCJ4 and repserver90 are running, now, I attempt to run one report from Forms9i, and only it appears an empty page HTML. I don't understand why doesn't show the data of query?
    Please, give me a solution for this problem, thanks for your help.
    PD: I am using the below code.......
    PROCEDURE bring_report IS
    repid REPORT_OBJECT;
    v_rep VARCHAR2(100);
    rep_status VARCHAR2(20);
    BEGIN
    repid := find_report_object('Q_DATA1');
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,BATCH);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESTYPE,CACHE);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'html');
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER,'repserver90');
    v_rep := RUN_REPORT_OBJECT(repid);
    rep_status := REPORT_OBJECT_STATUS(v_rep);
    WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED')
    LOOP
    rep_status := report_object_status(v_rep);
    END LOOP;
    IF rep_status = 'FINISHED' THEN
    /*Display report in the browser*/
    WEB.SHOW_DOCUMENT('http://172.16.2.18:8888/reports/rwservlet/getjobid'||
    substr(v_rep,instr(v_rep,'_',-1)+1)||'?'||'server=repserver90','_blank');
    ELSE
    message('Error when running report');
    END IF;
    END;

    Alex,
    the code does look good. maybe the Reports query does not produce an output. You can trace this ny adding a header on top of teh Reports (e.g. a date or just saying "Hello World"). So instead of an empty page this should now show the text strings. If you don't see the string then there is something else going on. Since you are not getting any error message I assume that the Reports itself executes fine.
    Frank

  • BIEE 10g combine month and day data in one report

    Hi
    I am trying to build a simple model to report employee absence per day against number of employees per month.
    There are two challenges:
    a) not setting content level of No_of_employees, drilling down along calendar to day level shows the Absence_day numbers, but not the number of employees for the month
    b) setting the content level of No_of_employees to month repeats the numbers correctly for each day in a month, but does not aggregate No_of_employees at a higher level (quarter or year)
    How do I achieve a report like this without loosing the ability to aggregate numbers at year level?
    Report sample
    Year     Month     Date     No_of_employees     Absence_day
    2012     June     06/01     15000               10
    2012     June     06/02     15000               8
    2012     June     06/03     15000               14
    2012     June     06/04     15000               5
    2012     June     06/05     15000               6
    OBIEE Version: 10.1.3.4.1 (not patched in a while)
    The calendar dimension has been build using OWB. Year, quarter and month level do contain negative dimension keys for values at these levels and f_employee joins to the negative values. The lowest level is day (positive dimension key values).
    Month June 2012; D_calender.dim_key = -50 (negative value !)
    Dates in June 01 - 30, D_calender.dim_key = 100 - 130 (positive values)
    Dimension: Calendar
    logcial levels: year - Quarter - Month - Detail (= date)
    logical key: Date
    LTS Fact 1: employees
    at month level
    physical join: f_employee.cal_fk = D_calender.dim_key
    measure: No_of_employees
    aggregation: sum
    logical:
    LTS content level: Calender dimension set to Month
    LTS Fact 2: absence
    at day level
    physical join: f_absence.cal_fk = D_calender.dim_key
    measure: Absence_day
    aggregation: sum
    logical:
    LTS content level: Calender dimension set to Detail (= date)
    Both facts are LTS for the same Logical Fact table.
    Thanks for your help
    Regards
    Andy

    The SQL I get when executing a request:
    If I could get Answers to display values of c9 instead of c5 (last few lines of the SQL), my problem may be solved
    WITH
    SAWITH0 AS (select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4
    from
    (select sum(nvl(T116806.FRAVAERSDAG , 0)) as c1,
    T116670.DATO as c2,
    T116670.AAR_NR as c3,
    T116670.MAANED_NAVN as c4,
    ROW_NUMBER() OVER (PARTITION BY T116670.DATO ORDER BY T116670.DATO ASC) as c5
    from
    DM2.D_KALENDER_HIER T116670 /* Aggregation_D_Kalender_Hier */ ,
    DM2.F_FRAVAERSPERIODE_DAG_V2 T116806 /* Aggregation_F_FRAVAERSPERIODE_DAG_V2 */
    where ( T116670.AAR_NR = 2012 and T116670.DIMENSION_KEY = T116806.D_KALENDER_FK and T116670.MAANED_NAVN = 'April' )
    group by T116670.AAR_NR, T116670.DATO, T116670.MAANED_NAVN
    ) D1
    where ( D1.c5 = 1 ) ),
    SAWITH1 AS (select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3
    from
    (select sum(T116663.ANSAT) as c1,
    T116670.AAR_NR as c2,
    T116670.MAANED_NAVN as c3,
    ROW_NUMBER() OVER (PARTITION BY T116670.MAANED_NAVN ORDER BY T116670.MAANED_NAVN ASC) as c4
    from
    DM2.D_KALENDER_HIER T116670 /* Aggregation_D_Kalender_Hier */ ,
    DM2.F_ANSAT_I_MAANED_LOENUDB_V2 T116663 /* Aggregation_F_ANSAT_I_MAANED_LOENUDB_V2 */
    where ( T116663.KALENDER_DIM_HIER = T116670.DIMENSION_KEY and T116670.AAR_NR = 2012 and T116670.MAANED_NAVN = 'April' )
    group by T116670.AAR_NR, T116670.MAANED_NAVN
    ) D1
    where ( D1.c4 = 1 ) )
    select case when SAWITH1.c2 is not null then SAWITH1.c2 when SAWITH0.c3 is not null then SAWITH0.c3 end as c1,
    case when SAWITH0.c4 is not null then SAWITH0.c4 when SAWITH1.c3 is not null then SAWITH1.c3 end as c2,
    SAWITH0.c2 as c3,
    SAWITH0.c1 as c4,
    cast(NULL as INTEGER ) as c5,
    SAWITH0.c1 as c6,
    SAWITH1.c1 as c9
    from
    Sawith0 Full Outer Join Sawith1 On Nvl(Sawith0.C4 , 'q') = Nvl(Sawith1.C3 , 'q') And Nvl(Sawith0.C4 , 'z') = Nvl(Sawith1.C3 , 'z')
    order by c1, c2

  • Query of month to date

    <u></u>
    Hi all,
    i need to define a query to restrict the key figure base on month to date(current date") of this year, and the range of last year.
    **let's say today i run the query, and today is 11 of Aug,so i want to get the this year's Month to date total sales(sales value from 01 of Aug till 11 of Aug);
    and since 1 of Aug is Monday, and 11 of aug is the following week Thuesday.
    ***I also want to get last year's Month to date total sales(sales value from first week Monday of last year Aug, which is 2 of Aug 2004, till the second week Thuesday of last year Aug, which is 12 of Aug lsat year)-- altough soemtime, the first week Monday of last year may fall to end of July, it still calucation these way.
    I know I should define few variabels to restricted the key figures, but i am not sure
    --what function module I should use to get the first date of current month; and in which date of week(Sunday ,Monday or Tuesday..) it falls into?
    -- what is the good way to get the query done.
    Waiting for your adice,
    Ping

    I found one FM called:
    RS_VARI_V_1_ACTUAL_MONTH 
    it get the First day of current month.
    ""Lokale Schnittstelle:
    *"       EXPORTING
    *"             VALUE(P_DATE) LIKE  SY-DATUM
    *"       TABLES
    *"              P_INTRANGE STRUCTURE  RSINTRANGE
    but i don't know how to use it, where i can get the first day  of current month imported?? how to use this P_INTRANGE table? could any one help to to write a sample code to show me.
    Thank you a million!!
    Ping

  • How Should select default (Apr-mar)month in cross tab?

    HI Experts,
    I have created webi report with cross tab format. In this report how should select  Current year (April Month) to Next Year (March Month).
    For Example:
    2013 apr.......2014 may

    Hi Manikandan,
    Similar to your previous post about selecting Fiscal Year, do this in BEx, Have a range on Fiscal Month which either the user can input the range or use Customer Exits to derive it.
    The in your cross tab, having Fiscal Month in your columns will show the range selected.
    with regards
    Gill

  • How can I Move data from one column to another in my access table?

    I have two columns, one that stores current month’s data and one that stores last month’s data. Every month data from column 2 (this month’s data) needs to be moved to column 1 that holds last month’s data. I then null out column 2 so I can accumulates this month’s data.
    I understand how to drop a column or add a column, how do I transfer data from one column to another.
    Here is my trial code:
    <cfquery name="qQueryChangeColumnName" datasource="#dsn#">
      ALTER TABLE leaderboard
      UPDATE leaderboard SET  points2 = points3
    </cfquery>
    Unfortunately, I get the following error:
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in ALTER TABLE statement.
    How can I transfer my data with the alter table method?

    I looked up the Access SQL reference (which is probably a
    good place to start when having issues with Access SQL), and
    it suggests you probably need a WHERE clause in there.
    I agree the documentation is a good place to start. But you should not need a WHERE clause here.
    Too few parameters. Expected 1.
    If you run the SQL directly in Access, what are the results? At the very least, it should provide a more informative error message..

  • Time phase Min/max replenishment models for future dates

    Hi,
    We are working on a safety stock requirement of Maximum/Minimum replenishment model in APO.
    It seems to work great except it cannot be time phased.  Our business wants different safety stock strategies at different times of the year. 
    Please suggest if there is a way that we could “time phase” min/max replenishment models for future dates?
    Thanks in advance for your help!
    regards
    Yogendra

    Many thanks for this.
    I can see entirely why it's designed as such, but I just find it slightly frustrating that there's no way to break the link between the order and the shipment out to the depot. Just to clarify, we're not requiring the orders to change - they will still be made and will come in - but just that the orders themselves don't specifically need to be the stock that is used for the replenishment.
    So -
    1. Min Max identifies depot needs replenishing.
    2. Central distribution does not have (enough) stock to replenish.
    3. Order is made to replenish central distributions stock.
    4. We ship whatever we've got, when we've got it, to depot to replenish.
    It's the bit where Min-Max is trying to replensih a specific depot rather than our central distribution centre that's my problem.
    I suspect that, as you say, that specific issue is not directly fixable without getting our IT contractors to do a customisation.
    I'm going to look into your Supply Date Offset suggestion now, though I'm not sure how this affects the shipping after the orders are placed. The orders themselves are approved manually after we've checked our stock position (i.e. what's in with the recycling team), but we recycle & refurb probably 60% of our maint stock so there'll always be kit turning up after the order has been made because of the long lead times.
    Thanks again.

Maybe you are looking for

  • URGENT !!! - unwanted padding-top in IE but not in FF - HELP !!!

    Hi guys - please help me urgently! The attached page is self-explanatory. This is regular 2-columns setup: main content, right sidebar, header and footer. Right sidebar is floating DIV element. Whatever is inside it is positioned well in Firefox but

  • Default Gateway when connected to VPN

    Thanks for reading! This is probably a dump question so bear with me... I have set up a VPN connection with a Cisco ASA 5505 fronting internet, with the customers environment behind it (on the same subnet), When connected ot the VPN I can reach the i

  • Laptop keeps shutting off

    I bought my MacBook about three weeks ago, and in the past week, it's started to randomly turn off when I'm using it. And sometimes when I turn it on, it will shut down within a few seconds...sometimes the screen lights up and I can hear it turning o

  • Skype Crashes Randomly

    This is the error from Event Viewer when it crashes. It did this a awhile ago and how I fixed it was going into my computer and changing Skype to SkypeOld and basically restarting Skype. Now it's doing it again. I didn't update/change any software, s

  • Registration key issue.

    Allright...I bought a Quicktime Pro key, and enter EXACTLY how it says in the registration fields...click apply, and Quicktime Pro 7 pops up. My ISSUE is, after I hit OK and the window closes...the next time I watch a movie, all the Pro features are