Select the table based on 2 months ? Query no working

I have a table TEST1 in schema MESSAGE_REPORT. What i want to do is select the table based on 2 months ( JULY and AUGUST ). The requirement is Whole JULY data should be there and for AUG the data should be till 01 aug . Below is the query i m using but its giving me error . Moreover the Where clause "TRUNC(HIRE,'MONTH') " part is compulsary to be used ,changes have to be made in the ">= timestamp '2010-07-01 00:00:00' and frd.sent_timestamp < timestamp '2010-08-10 00:00:00';" part only . please can anyone help me out
NAME        HIRE
SALE     01.07.2010 00:00:00,000000000
cops     15.07.2010 00:00:00,000000000
NAVEED     31.07.2010 00:00:00,000000000
HEN     01.08.2010 00:00:00,000000000
BEN     10.08.2010 00:00:00,000000000
CROSS     15.08.2010 00:00:00,000000000
select * from MESSAGE_REPORT.test1 where
TRUNC(HIRE,'MONTH') >= timestamp '2010-07-01 00:00:00' and frd.sent_timestamp < timestamp '2010-08-10 00:00:00';
ERROR:
ORA-00904: "FRD"."SENT_TIMESTAMP": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:   
*Action:
Error at Line: 24 Column: 60Edited by: user12633486 on Aug 11, 2010 1:13 PM
Edited by: user12633486 on Aug 11, 2010 1:51 PM

Thats becuase you are comparing with Month and not the complete date.
Check this:
SQL> ed
Wrote file afiedt.buf
  1  with t as (select 'SALE' col1,'01.07.2010 00:00:00' col2 from dual
  2  union all select 'cops','15.07.2010 00:00:00' from dual
  3  union all select 'NAVEED','31.07.2010 00:00:00' from dual
  4  union all select 'HEN','01.08.2010 00:00:00' from dual
  5  union all select 'BEN','10.08.2010 00:00:00' from dual
  6  union all select 'CROSS','15.08.2010 00:00:00' from dual)
  7  select * from t
  8  where
  9  TO_DATE(col2,'DD.MM.RRRR HH24:MI:SS') >= timestamp '2010-07-01 00:00:00'
10* and TO_DATE(col2,'DD.MM.RRRR HH24:MI:SS') < timestamp '2010-08-10 00:00:00'
SQL> /
COL1   COL2
SALE   01.07.2010 00:00:00
cops   15.07.2010 00:00:00
NAVEED 31.07.2010 00:00:00
HEN    01.08.2010 00:00:00
SQL>
-- For less than equal to
SQL> ed
Wrote file afiedt.buf
  1  with t as (select 'SALE' col1,'01.07.2010 00:00:00' col2 from dual
  2  union all select 'cops','15.07.2010 00:00:00' from dual
  3  union all select 'NAVEED','31.07.2010 00:00:00' from dual
  4  union all select 'HEN','01.08.2010 00:00:00' from dual
  5  union all select 'BEN','10.08.2010 00:00:00' from dual
  6  union all select 'CROSS','15.08.2010 00:00:00' from dual)
  7  select * from t
  8  where
  9  TO_DATE(col2,'DD.MM.RRRR HH24:MI:SS') >= timestamp '2010-07-01 00:00:00'
10* and TO_DATE(col2,'DD.MM.RRRR HH24:MI:SS') <= timestamp '2010-08-10 00:00:00'  -- less than equal to includes data for 10th august as well
SQL> /
COL1   COL2
SALE   01.07.2010 00:00:00
cops   15.07.2010 00:00:00
NAVEED 31.07.2010 00:00:00
HEN    01.08.2010 00:00:00
BEN    10.08.2010 00:00:00
SQL> Edited by: AP on Aug 11, 2010 1:31 AM
Edited by: AP on Aug 11, 2010 1:32 AM

Similar Messages

  • Is it possible to find the  table based on the Date ?

    Dear Team ,
    Is it possible to find the table based on the Date ?
    I have created an table ,But forgot the Table Name .
    Is it possible to find the Tables created on particular Date .
    Regards ,
    Augustine

    as date is record the time also below query will work.
    select * from user_objects
    where
    object_type = 'TABLE' and
    to_date(created,'DD-MON-YYYY') =to_date('<your date value in DD-MON-YYYY format>','DD-MON-YYYY');
    Edited by: shaileshM on Feb 24, 2010 9:39 PM

  • Adobe Acrobat Pro XI 11.0.06 when I reduce file size or try to optimize, I get this error: The document could not be saved. A number is out of range. I do the exact same thing every month and it works. I did it a few days ago and it worked. I receated the

    Adobe Acrobat Pro XI 11.0.06 when I reduce file size or try to optimize, I get this error: The document could not be saved. A number is out of range. I do the exact same thing every month and it works. I did it a few days ago and it worked. I receated the pdf, I renamed it. tried to do it before I imported more pages. no go. the 16 mg pdf will normally reduce to 5 or 6

    Hi,
    Are you facing the issue with any pdf file?
    Please try updating Acrobat to 11.0.7 and check.
    You might also want to repair Acrobat and see.
    Regards,
    Rave

  • To divide the table based on number of rows

    Hello,
    I am trying to divide a table based on the number of rows and then to process it.
    Say i have a table TEST_XXX which contains 50 rows, what i would like to do is,
    to access rows in multiple of 10. How can we do this ?
    What i was thinking is, once the table gets created and row are filled in,
    add a new column to the table and run a procedure which inserts 1 to first 10 rows
    and 2 to next 10 rows and 3 to next 10 row ...etc. Based on this we can process
    the first set of rows then next set or rows etc ....
    is there a better way to do this ?
    Code to create the table :
    CREATE TABLE TEST_XXX
      A_ID   VARCHAR2(10),
      B_ID   NUMBER,
      c_ID   VARCHAR2(10),
      D_ID   NUMBER
    )Code to add rows:
    DECLARE
    BEGIN
      FOR I IN 1..50
      LOOP
          INSERT INTO TEST_XXX VALUES('ABCDE',123,'ZYXWV',321);
      END LOOP;
      COMMIT;
    END;The original problem is, i do have a huge table, and i write a sql query to process it,
    when i process it selecting all values from table, it is very slow.
    But when i process it in small chuks(say 100 rows) it works fine.
    Thats how i was the above approach in mind.

    The original problem is, i do have a huge table, and i write a sql query to process it,
    when i process it selecting all values from table, it is very slow.Did you trace both the implementations and see why it is taking longer?

  • How do I select the items based on their adjacent equality?

    In the below table,
        DECLARE @t1 TABLE(id INT,NAME VARCHAR(MAX))
        INSERT INTO @t1 VALUES(1,'test')
        INSERT INTO @t1 VALUES(2,'test')
        INSERT INTO @t1 VALUES(3,'best')
        INSERT INTO @t1 VALUES(4,'rest')
        INSERT INTO @t1 VALUES(5,'rest')
    how can I select the records that have equals values coming adjacently? That is I am running an SQL job. It should take the adjacent equal value  count for its processing. In the below table, first time the job is running it should take count as 2 the
    2nd time job is running it should be 1. Third time it should be 2. What is the query that will fetch the cont of equal records for name column? In case no equal columns it should be 1. Please help
    mayooran99

    Hi
    Try the following code.
    DECLARE @t1 TABLE(id INT,NAME VARCHAR(MAX))
    INSERT INTO @t1 VALUES(1,'test')
    INSERT INTO @t1 VALUES(2,'test')
    INSERT INTO @t1 VALUES(3,'best')
    INSERT INTO @t1 VALUES(4,'rest')
    INSERT INTO @t1 VALUES(5,'rest')
    INSERT INTO @t1 VALUES(6,'test')
    INSERT INTO @t1 VALUES(7,'best')
    INSERT INTO @t1 VALUES(8,'best')
    INSERT INTO @t1 VALUES(9,'vest')
    --ranking adjacent names, running total
    SELECT rs.id, rs.NAME, ROW_NUMBER() over (partition by name, nxt_id order by id) RankingCount
    FROM (
    SELECT nxt.id, nxt.NAME,(SELECT min(s.id)
    FROM @t1 s
    WHERE s.name <> nxt.name
    AND s.id > nxt.id
    ) as nxt_id
    FROM @t1 nxt) rs
    ORDER BY rs.id;
    --code to just return the totals
    with cteTotals
    as
    SELECT rs.id, rs.NAME, ROW_NUMBER() over (partition by name, nxt_id order by id) RankingCount, nxt_id, ROW_NUMBER() over (partition by name, nxt_id order by id desc) Ranking
    FROM (
    SELECT nxt.id, nxt.NAME,(SELECT min(s.id)
    FROM @t1 s
    WHERE s.name <> nxt.name
    AND s.id > nxt.id
    ) as nxt_id
    FROM @t1 nxt) rs
    select Name, RankingCount
    from cteTotals
    WHERE Ranking=1
    order by id
    The first query keeps a running total of adjacent names, the second one just reports the totals

  • Unable to lead select the table

    Hi All ,
    i i have some requirement something like this i have three table side by side in a view when i select the row of the first table the data in the second table should be dislayed and similarly for the third table as well .
    Now my problem is when i am lead selecting the first table i a able to fetch the data and display but i am unable to lead select that rows in the table to display the lead selection i used Lead selection by Index then is is displaying properly BUT when i click on the second row or the third row or so...... It is not getting lead selected. I am Surprised i tried to check but did not found a single clue please help me with this.......
    Good Day....................
    Thanks and Regards,
    Sana.

    hi ,
    did u check the LeadSelect property of ur context node to which ur table is binded ?
    http://help.sap.com/saphelp_nw04s/helpdata/EN/79/555e3f71e41e26e10000000a114084/content.htm
    regards,
    amit

  • Dynamic SQL statement to select the tables which are updated today...

    Hi Guys,
    I need to find the names of all the tables which contain rows that are inserted/updated in a given time stamp...
    Below statement gives me the list of all the tables in the database...
    select t.table_name from all_tables t;All these tables in the database have a column called rowversion which gives the updated/inserted date of a record. I need to write a select statement (probably dynamic) which will give me the table names which contain the rowversion value 24-01-2013....
    Any help is very much appreciated...

    Napster wrote:
    Hi Karthick,
    Thanks for your reply...
    But when I execute your select statement I am getting an error saying table SYS.DBMS_XMLGEN does not exist.
    Probably something wrong in my environment?Yes you can, here is a quick untested code
    declare
      my_filter date := to_date('24-01-2013', 'dd-mm-yyyy');
      my_count integer;
    begin
      for i in (select table_name from user_tables)
      loop
         execute immediate q'[select count(*) from ]' || i.table_name || q'[ where rowversion = :1]'
         using my_filter
         into my_count;
         if my_count > 0 then
             dbms_output.put_line(i.table_name);
         end if;
      end loop;
    end; 
    /

  • Displaying the table based on number of records.

    Hi Experts,
    I want to display a normal table based on the records, if there is only one record then only one row should be displayed on the table, if there are 2 records then 2rows should be displayed on the table with the data, if they are more than 2 records only 2 rows should be displayed on the table and remaining rows should be able to scroll on the table.
    Please Provide the requried infformation.
    Thanks & Regards.
    Bhushan.

    Hi Bhushan
      What exactly is row scroll? Did you not refer to the vertical scrollbar that appears when the number of rows is more than the number of displayed rows? Please clarify
    If it is the vertical table scroll bar you refered to then you will get it if the number of records are more than the visibleRowCount you set
    If it is the horizonal table scroll bar you refered to then you will get it by setting a fixed width to the table. If your column(s) value width exceeds the table width you have specified, you get the horizontal scrollbar.
    Regards,
    Gayathri Shanbhag

  • Select the record based count condition

    Hi Experts
    I have a table with columns  StateDate,State,Name & Type . For the same date there could be 2 or more rows for the same name .
    I need to retrieve the data from the table only for the name containing single row in the table and state = 'On'
    Please find the Create & Insert Scripts below . Am assuming it needs to be done with a window function and am not yet comfortable with window function .
    CREATE TABLE ItemState
    (StateDate Date,
    State Varchar(3),
    Name Varchar(3),
    Type int)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','Off','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','ABC',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','Off','CBR',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','On','CBR',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','On','XYZ',1)
    Expected Result
    StateDate
    State
    Name
    Type
    3/11/2014
    ON
    ABC
    1
    3/12/2014
    ON
    XYZ
    1
    Kindly help
    Thanks
    Priya

    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','Off','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','ABC',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','Off','CBR',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','On','CBR',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/12/2014','On','XYZ',1)
    again adding this 3 rows 
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','Off','XYZ',1)
    INSERT INTO Itemstate (Statedate,State,Name,Type)
    Values ('3/11/2014','On','ABC',1)
    SELECT *
    FROM   itemstate order by statedate, name,state
    2014-03-11 On
    ABC 1
    2014-03-11 On
    ABC 1
    2014-03-11 Off
    XYZ 1
    2014-03-11 Off
    XYZ 1
    2014-03-11 On
    XYZ 1
    2014-03-11 On
    XYZ 1
    2014-03-12 Off
    CBR 1
    2014-03-12 On
    CBR 1
    2014-03-12 On
    XYZ 1
    so only xyz on 2014-03-12 will qualify
    WITH test
         AS (SELECT *,
                    row_number()
                      OVER (
                        partition BY statedate, name
                        ORDER BY state ASC) rnasc, 
    count(state)
                      OVER (
                        partition BY statedate, name
                        ORDER BY state desc) rncount
             FROM   itemstate)
    SELECT *
    FROM   test t1  where rnasc = 1 
    and state = 'on' and rncount = 1
    Amish shah
    http://bloq.sqltechie.com

  • ALV - selecting the data based on layout set in selection screen

    Hi,
    I have an ALV report (Custom). I want to give layout selection at selection screen, so the user can create/select/manage layout at the time of selection screen and only these columns will be displayed in the final output. Instead user execute the report for all column and at the end user select the layout. I want this layout at the selection screen level like the standard reports.
    Thanks,

    You can do the following
    When the user clicks on download
    1.Use FM REUSE_ALV_LIST_LAYOUT_INFO_GET / REUSE_ALV_GRID_LAYOUT_INFO_GET to get the Fieldcat (since due to selection of layout on sel screen some columns are disabled. For the columns which have been disabled the resultant Fieldcat from the above FMs would have NO_OUT = 'X'. Delete columns from Fieldcat itab where no_out = 'X'
    2.create a dynamic itab using cl_alv_table_create=>create_dynamic_table( )  passing the above Fieldcat itab, get a handle of new itab
    3.loop over the original itab and fill the new dynamic itab
    hope this helps...

  • Tableview setting to enable to select the table columns to display

    Hi All,
    In webdynppto in the table ALV display we have the settings option with which users can control what columns of the table to display and what columns to hide in the table display.
    Users can also control the columns of the display to show or hide in the display. Can any of you please clarify how we can do this with the tableview
    The tableview I am using is below what setting do I need to enable to get the column display/hide by users at runtime
    Thanks
    Karen
    <%@page language="abap" %>
    <%@extension name="htmlb" prefix="htmlb" %>
    <htmlb:content design="design2003" >
    <htmlb:page>
    <htmlb:form>
    <htmlb:tableView id = "tv1"
    visibleRowCount = "10"
    selectionMode = "lineEdit"
    table = "<%= flights %>"
    filter = "SERVER"
    sort = "server"
    iterator = "<%= iterator %>" />
    </htmlb:form>
    </htmlb:page>
    </htmlb:content>

    hello,
    I do not think it's possible dynamically like ALV...on screen itself...
    to hide / display a column you can code in iterator class with some condition...
    Thanks,

  • Need to run a query to select # of counts based on each month

    Let's say I have a talble with 12 months, each month has some data.
    I want to run a select count(*) to get result of how many rows per month, like Jan----100, Feb---90, etc.
    How do I do that?
    Thanks in advance.

    user569151 wrote:
    Let's say I have a talble with 12 months, each month has some data.
    I want to run a select count(*) to get result of how many rows per month, like Jan----100, Feb---90, etc.
    How do I do that?
    Thanks in advance.May be like this:
    SELECT EXTRACT(MONTH FROM date_column),COUNT(*)
    FROM TABLE_NAME
    GROUP BY EXTRACT(MONTH FROM date_column);

  • User able to select the table,yet unable to fetch data..Strange!!

    Hi Experts,
    I have a USER who is being granted a SELECT priv on particular table. He tried to fetch the data, but yeilds 0 bytes at the end..
    Here is a detail:
    GRANTEE OWNER TABLE_NAME GRANTOR PRIVILEGE GRA HIE
    UMA DNBPRIME DNB_SKAR_PEOPLE DNBPRIME SELECT NO NO
    SQL> connect uma/******
    Connected.
    SQL> select count(*) from dnbprime.dnb_skar_people where fragmentindicator = 1304;
    COUNT(*)
    0
    For me it is quite strange, but I guess some security policy may be in place. But the issue is my client wants to fetch the data. What should I do Now.
    Regards,

    >
    So It seem s I was bit right..There are some FINE GRAINED ACCESS restrictions in place..
    >
    Based on what? Just because SB suggested it?
    If you did some checking and found there is some RLS in place post what you did and what the results were. This forum is to help everyone understand what is happening not just to answer your question.
    >
    I have a USER who is being granted a SELECT priv on particular table. He tried to fetch the data, but yeilds 0 bytes at the end..
    >
    That user was granted privileges to see their data. They don't have any data to see.
    >
    Any workaround to fetch the data.
    >
    Sure - look through your DBAs desk and computer when they are at lunch. Often they will leave their password written down somewhere and you can sneak a copy of it.
    That way you can violate your company's security policy whenever you want and if anything bad happens they will blame the DBA.
    The 'workaround' is to get permission for the RLS policy to be changed or permission for the user to use a different account that can see the data.

  • SRM MDM - store multiple pricing for one entry and have it select the price based on a users site

    I've had an interesting request. We have a region where they have one supplier who will support some products for multiple sites. The sites are in different cities and so the pricing varies based on the location of the user. I know how to do price scaling in SRM MDM but wasn't sure if there was a way to have one part that could someone pick the right price based on the user. I don't think this can be done since we don't pass any "user" information in the OCI connection.
    Has anyone run into this scenario and was there some other way to not duplicate the entries or create a separate view just because the pricing was different for the same product but different site? I'm open for suggestions. I'm looking to make long term maintenance of the data as easy as possible.
    We are still running SRM MDM 5.5 SP6
    Thanks,
    Cathy

    Tom,
    Check if the below given link can give you some lead.
    http://help.sap.com/saphelp_NW04/helpdata/en/dc/dc7614099b11d295320000e8353423/content.htm
    Thanks,
    K.Kiran.

  • How to select a table based on a button event

    Can we make control in row selection?
    For eg, i have added a button in my column. So it will be displayed in all rows.Clicking on the button the entire row should be selected.How to do it.
    Thanks in advance

    Hi Kishore,
    Add the press event handler for your button as below,
    new sap.ui.commons.Button({press:function(oEvent){
      oTable.setSelectedIndex(oEvent.getSource().getParent().getIndex());
    Refer to this snippet http://jsbin.com/kikubupa/1/edit
    regards
    sakthi

Maybe you are looking for

  • Value  set in constructor is not getting saved in button  Action method

    Hi All, I am not understanding why the value set ( On Condition )in constructor is not hold in the button actoin method. Could any body explain me on that for this I will try to explain with sample example I have taken a button and add a integer prop

  • Mobile albums not downloading from Revel in Photoshop Elements 12

    Photoshop Elements 12 is not downloading my photos from my Revel Libraries.  I have about 10 libraries and it is only downloading from one of them.  Revel Agent just says "detecting Changes" for several hours now.  How do yu get Photoshop Elements to

  • Changing from 32 bit to 64?

    i,m new to logic 9 and i noticenot all of my a.u.s seem to be available (third party) i was wondering if i should work in 64 bit mode then maybe all of my plug ins will be there?

  • Does Business Partner have one Contract Account per premise ?

    Hi, Business Master Data a) Business partner b) Contract Account c) Contract Technical Master Data a)Connection Object b)Premise c)Installation. Relations: One Business Partner will have multiple Contract Accounts One Contract Account will have multi

  • "NetStream.Codec.Error" record RTMFP

    I record RTMFP Stream. Use this code NetGroup ng application.recordStream[nick + "multicast"] = Stream.get("mp4:multicast-ingest" + nick +"_record" +".mp4"); if ( application.recordStream[nick + "ingest"] != null )           application.recordStream[