Query to to pcik part of data

i want to create one new column. that new column is depends on two columns like below
Column1 Column2 Column3
AB ABAberchrombie Aberchrombie
CDE CDEHollister Hollister
FGHI FGHIAmerican Eagle American Eagle
Here i want to create new column - column3 in Business layer from column1 and column2.
anyone give me the query for create column3?
Thanks in advance
Edited by: user12255470 on Oct 8, 2011 1:44 AM

Hi,
You can try using Substring function to create column3.
SUBSTRING(column2 FROM LENGTH(column1) + 1)
Create a new logical column - column3 and mention above expression in the formula.
Thanks

Similar Messages

  • How can I use today's date as default value in query string filter web part in SharePoint

    I have a query string filter on my web part page. I am trying to figure out how I can set it's default value to Today? I can't find anything online...

    Hi,
    Per my understanding, you might want to set a default value to the Query String Filter Web Part.
    It would not be able to set default value to the Query String Filter Web Part with the OOTB features available.
    By default, with a Query String Filter Web Part in the current page, we can filter other web part in the same page by adding parameters and values in the address bar
    of browser.
    If setting the “Query String Parameter Name” of a Query String Filter Web Part as “t”, then we can filter the corresponding connected web part by inputting such an
    URL into the address bar:
    http://sharepoint/SitePages/Page1.aspx?t=value1
    Suppose you want to filter the list view with a value dynamically when user opens this page, as a workaround, we can generate an URL with the parameters needed when
    page loaded, then redirect user to this URL afterwards. This can be achieved using JavaScript.
    About how to redirect user to other page with an URL:
    http://www.tizag.com/javascriptT/javascriptredirect.php
    How to get today’s date using JavaScript:
    http://www.w3schools.com/js/js_dates.asp
    Best regards      
    Patrick Liang
    TechNet Community Support

  • Execution of queries - retreiving a part of data from database.

    I use EJB3, OC4J, Oracle9i.
    I try to get a part of data from database.
    I write such code:
    String sql = "SELECT object(o) FROM some_table o ORDER BY o.username ASC";
    Query partialListQuery = em.createQuery(sql);
    partialListQuery.setFirstResult(0);
    partialListQuery.setMaxResults(10);
    List<IssueHours> issueHoursList = partialListQuery.getResultList();
    and in logs I get:
    2006.11.16 11:09:06.224--ServerSession(977)--Connection(4561)--Thread(Thread[ApplicationServerThread-0,5,RequestThreadGroup])--SELECT ID, NUMBER, HOURS, SUMMARY, PROJECT_NAME, USERNAME FROM SOME_TABLE ORDER BY USERNAME ASC
    It is interesting whether some optimized query is built for retreiving a part of data or all data is carried from database to the server-side and filterred there.
    If all data is retreived, how can I avoid that?is there any configuration? or... must I create myself optimized query?

    When maxResults is set the JDBC maxRows is set which allows the database to optimize what results are returned. Only the maxResults are returned from the database.

  • Sql query-filter if 1 set of data exists and in the same time 2 set doesnt

    Hi guys,
    I need to write a query where I filter on certain data being present, but in the same time other data from the same table being not present.
    For example:
    ProceduresTable:
    Type 1
    Type 1
    Type 2
    Type 2
    Type 1
    MyTable:
    Name
    OtherFields
    JoiningTable (many to many)
    ProceduresTable_Key
    MyTable_Key
    I need to select all records from MyTable and Procedures for which there are procedures from Type 1 but there are no procedures from Type 2 in the same time.
    So far I've been only able to do that by using subqueries and I think there should be an easier way to do that.
    Here is what I have:
    Select * From MyTable, Procedures, JoiningTable Where JOINING_CONDITIONS AND Type = 1 AND NAME_SOME_COLUMN NOT IN (SELECT NAME_SOME_COLUMN FROM ... WHERE Type = 2 and inner.Name = outer.Name)
    Hope you understand my meta code. I have Oracle 9 db.
    Thanks a lot!

    Hi,
    Welcome to the forum!
    Whenever you have a question, it helps if you post a specific example. Include CREATE TABLE and INSERT statements for a little sample data, and also post the results you want from that data.
    if you can use commonly available tables (like those in the scott or hr schemas) to illustrate your proble, then you don't have to post the sample data; just the results.
    For example, I think you're asking something like this:
    "How can I find information about people in the sciott.emp table who are in a department that has at least one CLERK ( that is, a row with job='CLERK') but no SALESMAN? That is, I want these results:
    {code}
    ENAME DEPTNO JOB
    CLARK 10 MANAGER
    KING 10 PRESIDENT
    MILLER 10 CLERK
    JONES 20 MANAGER
    FORD 20 ANALYST
    ADAMS 20 CLERK
    SMITH 20 CLERK
    SCOTT 20 ANALYST
    {code}
    One way is to use CASE expressions instead of WHERE clauses to test for the criteria, then using the reults of the CASE expressions in the WHERE clause.
    For example:
    WITH     got_cnts     AS
         SELECT     ename,     deptno,     job
         ,     COUNT ( CASE
                             WHEN  job = 'CLERK'
                       THEN  1
                         END
                    ) OVER (PARTITION BY deptno)     AS clerk_cnt
         ,     COUNT ( CASE
                             WHEN  job = 'SALESMAN'
                       THEN  1
                         END
                    )     OVER (PARTITION BY deptno)     AS salesman_cnt
         FROM     scott.emp
    SELECT     ename,     deptno,     job
    FROM     got_cnts
    WHERE     clerk_cnt     > 0
    AND     salesman_cnt     = 0
    ;The problem here is that you can't always tell, by looking at any one row, if it should be included or not; in this case, you need to know something about the department as a whole. Analytic functions can look at the department as a whole, but analytic functions are computed after the WHERE clause is applied, so to use the results of the analytic functions in a WHERE clause, we need to do the analytics first, in a sub-query, and the WHERE clause later.
    Sometimes (as in the example above) analytic functions are useful; other times, aggregate functions are more appropriate, depending on the exact requirements.
    Edited by: Frank Kulash on Apr 12, 2010 9:00 AM

  • How to get a time part from Date datatype

    Hi,
    I would like to know how to extract the timestamp alone from DATE datatype? If my input is '27-SEP-2011 23:59:00' I need the output as 23:59:00. I am surprised to see that there are no in-built functions for this or may be I am wrong. Basically I need to remove the date part from DATE data type and get the time.Please assist.
    -Thanks
    Edited by: user9546145 on Sep 27, 2011 2:24 PM
    Edited by: user9546145 on Sep 27, 2011 2:25 PM

    Hi,
    user9546145 wrote:
    Hi,
    I would like to know how to extract the timestamp alone from DATE datatype? Be careful! In Oracle, TIMESTAMP means a datatype, similar to but distinct from DATE. You'll avoid confusion if you don't use the word "timestamp" to mean anything else.
    There is a built-in function, TO_CHAR:
    TO_CHAR (dt_col, 'HH24:MI:SS')Depending on how you plan to use the time, TRUNC is another handy built-in function:
    dt_col - TRUNC (dt_col)is a NUMBER (not less than 0, but less than 1) which is suitable for many tasks, such as finding the average time.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.

  • Query to find the  second maximum date in a table

    please give me the query to find the second maximum date in a table

    You can try with this
    SELECT empno
          ,hiredate
      FROM emp        a
    WHERE 2          = (SELECT COUNT(DISTINCT hiredate)
                           FROM emp        b
                          WHERE b.hiredate      >= a.hiredate
    OR
    SELECT empno
          ,hiredate
      FROM (SELECT ROWNUM      row_num
                  ,empno
                  ,hiredate
              FROM emp        a
          ORDER BY hiredate   ASC
    WHERE row_num             = 2;Regards
    Arun

  • Query  to trace who updated the data

    query to trace who updated the data
    date
    and time
    and username

    ahh, ok - there's a few articles around that will assist.
    I suggest first
    you experiment with triggers to familiarise yourself with them:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/triggers.htm#CNCPT118
    this article here explains the process of putting in some audit processes using triggers:
    http://www.oracle-base.com/articles/9i/CompleteDataAudit.php
    it details creating the tables etc and then provides a procedure that will create the trigger text for you for each table you want to audit. it would be good to write your own trigger from scrath in order to learn and understand exactly what's happening, but it's up to you.
    let us know if you encounter any problems and we can help your specific problem

  • EJB Query Language where condtion based on date

    Hi,
    I am using EJB3 query language. In the table I have a column called requestdate which is in date time format. I have created an entity class.
    I need to select few records using query language(named queries) based on this requestdate matching to the current date. I want to compare only based on Date value (truncating the time). Something like this
    select max(o.req_id) from requests o where o.requestdate = :currentdate
    currentdate is java.sql.Date value formatted to yyyymmdd only.
    How can I do this using query language?
    Please help to me get this done.
    thanka
    Anuradha

    Hi Anuradha ,
    I'm afraid the query language does not support retrieving the date portion (i.e. truncating the time) from a date field.
    I propose you turn you named into a BETWEEN query taking two parameters one for the beginning of the day and another for the end of the day. Then your named query could look like:
    SELECT max(o.req_id) FROM requests o WHERE o.requestdate BETWEEN :start AND :end
    The following code creates two calendar instances for the current day, one for 00:00:00 and another for 23:59:59:
    Calendar start = Calendar.getInstance();
    start.set(Calendar.HOUR_OF_DAY, 0);
    start.set(Calendar.MINUTE, 0);
    start.set(Calendar.SECOND, 0);
    start.set(Calendar.MILLISECOND, 0);
    Calendar end = Calendar.getInstance();
    end.set(Calendar.HOUR_OF_DAY, 23);
    end.set(Calendar.MINUTE, 59);
    end.set(Calendar.SECOND, 59);
    end.set(Calendar.MILLISECOND, 999);
    Here is some sample code that creates a query instance for a named query called findMaxRequestPerDay and passes the Date of the above Calendar instance as actual parameter values. It assumes the named query is called findMaxRequestPerDay and the req_id field is a long:
    Query query = em.createNamedQuery("findMaxRequestPerDay");
    query.setParameter("start", start.getTime());
    query.setParameter("end", end.getTime());
    Long max = (Long)query.getSingleResult();
    I hope this helps.
    Regards Michael

  • Content query webpart use a part of the URL as filter

    Hey,
    I have on root site in the site collection a list. Now I like to build up a site template (from which the user can create sub sites form the root site in the site collection.
    In this site template I like to bring on the homepage a content query webpart. The content query webpart has to show one item from the list on the start site.
    How can I configure that the content query webpart use a part of the URL as filter?
    Url is like:
    http://Server/SiteCollection/ID/home.aspx
    The ID must be the filter criterion in the content query webpart. How can I do this?
    Thanks for your help
    Stefan
    Viele Grüße Stefan
    Kontakt unter [email protected]

    Hi Stefan,
    You can create your own CQWP by subclassing the default one.
    Then you can override the CAML query to add criteria found in the URL.
    Here is more information and sample:
    http://www.andrewconnell.com/blog/archive/2008/02/18/Subclassing-the-Content-Query-Web-Part-Adding-Dynamic-Filtering.aspx
    http://msmvps.com/blogs/laflour/archive/2008/05/29/subclassing-content-query-web-part-to-override-caml-query.aspx
    Regards,
    Ludovic Caffin

  • Modify MDX query so it only shows specific dates?

    I'm new to SSAS and SSRS reports (with datasource an SSAS cube), so please bear with me.
    So I created a basic report that gets the data from my SSAS cube and displays it. That is working well. The problem is that the parameter displays the Dimension [Dim Date].[Date Key] so the dropdown displays every single day in the dimension table.
    One of my datasets in the report is a hidden dataset called [DimDateDateKey]. This is the dataset used to display all the values in the datekey dropdown parameter. The MDX query looks like this:
    WITH MEMBER [Measures].[ParameterCaption] AS [Dim Date].[Date Key].CURRENTMEMBER.MEMBER_CAPTION MEMBER
    [Measures].[ParameterValue] AS [Dim Date].[Date Key].CURRENTMEMBER.UNIQUENAME MEMBER
    [Measures].[ParameterLevel] AS [Dim Date].[Date Key].CURRENTMEMBER.LEVEL.ORDINAL
    SELECT {[Measures].[ParameterCaption], [Measures].[ParameterValue], [Measures].[ParameterLevel]} ON COLUMNS ,
    [Dim Date].[Date Key].ALLMEMBERS ON ROWS FROM [Sales cube]
    My question is, how can I modify this query so that it only displays dates that are between today and 5 days ago? The column [Dim Date].[Date Key] is of type INT, so it would only display 20141012 and 20141017.
    Currently, it displays every single [Dim Date].[Date Key] of the table, which is from 20000101 to 20201231.
    Thanks.
    VM

    Hi VM,
    you have to dynamically filter data based on current date. Current date you can get using VBA function now().
    I enclose code adjusted code sample you pasted, but because I don't have same cube as you do, I wasn't able to execute it. Anyway it should work or at least you should see there that principle
    WITH MEMBER [Measures].[ParameterCaption] AS [Dim Date].[Date Key].CURRENTMEMBER.MEMBER_CAPTION MEMBER
    [Measures].[ParameterValue] AS [Dim Date].[Date Key].CURRENTMEMBER.UNIQUENAME MEMBER
    [Measures].[ParameterLevel] AS [Dim Date].[Date Key].CURRENTMEMBER.LEVEL.ORDINAL
    SELECT {[Measures].[ParameterCaption], [Measures].[ParameterValue], [Measures].[ParameterLevel]} ON COLUMNS ,
    [Dim Date].[Date Key].ALLMEMBERS ON ROWS FROM
    (SELECT {StrToMember("[Dim Date].[Date Key].&[" + Year(now()) * 10000 + month(now()) *100 + day(now()) + "]"):
    StrToMember("[Dim Date].[Date Key].&[" + Year(now()-5) * 10000 + month(now()-5) *100 + day(now()-5) + "]")}
    ON COLUMNS FROM
    [Sales cube]
    Jiri Neoral

  • Query to search between two specific dates and time period

    Hi,
    Need a query to search between two particular dates and time period
    Like i want to search table having one date field .
    Suppose the date range is '01-JUL-06' and '01-AUG-06' and time frame
    is 23:00:00 to 08:00:00
    i.e i want to search between dates 01 july to 01 aug and also within the time frame i.e 23:00 to 08:00 hrs only

    The general principle is
    SELECT * FROM your_table
    WHERE some_date BEWTEEN to_date('01-JUL-06') and to_date('01-AUG-06' )+0.99999
    AND  ( some_date <= trunc(some_date)+8/24
               OR  some_date >= trunc(some_date)+23/24 )
    /Cheers, APC

  • DATE QUERY (Need to find the financial dates)

    **I want to get the first and last financial dates of any year when i enter some date**
    Say, If i enter today's date "07-aug-2012", The query should written me the financial dates are 01-apr-2012 to 31-mar-2013
    And Note : That query should written me the financial dates of any year. (" not only this year alone ")
    Is there any possibility to find query for this?
    Shoot me if possible!!!

    with t as (
               select trunc(add_months(date '&enter_date',-3),'YYYY') fiscal_year from dual
    select to_char(add_months(fiscal_year,3),'DD-MON-YYYY') fiscal_year_start,
           to_char(add_months(fiscal_year,15) - 1,'DD-MON-YYYY') fiscal_year_end
      from t
    / For example:
    SQL> with t as (
      2             select trunc(add_months(date '&enter_date',-3),'YYYY') fiscal_year from dual
      3            )
      4  select to_char(add_months(fiscal_year,3),'DD-MON-YYYY') fiscal_year_start,
      5         to_char(add_months(fiscal_year,15) - 1,'DD-MON-YYYY') fiscal_year_end
      6    from t
      7  /
    Enter value for enter_date: 2012-08-07
    old   2:            select trunc(add_months(date '&enter_date',-3),'YYYY') fiscal_year from dual
    new   2:            select trunc(add_months(date '2012-08-07',-3),'YYYY') fiscal_year from dual
    FISCAL_YEAR FISCAL_YEAR
    01-APR-2012 31-MAR-2013
    SQL> /
    Enter value for enter_date: 2013-03-31
    old   2:            select trunc(add_months(date '&enter_date',-3),'YYYY') fiscal_year from dual
    new   2:            select trunc(add_months(date '2013-03-31',-3),'YYYY') fiscal_year from dual
    FISCAL_YEAR FISCAL_YEAR
    01-APR-2012 31-MAR-2013
    SQL> /
    Enter value for enter_date: 2013-04-01
    old   2:            select trunc(add_months(date '&enter_date',-3),'YYYY') fiscal_year from dual
    new   2:            select trunc(add_months(date '2013-04-01',-3),'YYYY') fiscal_year from dual
    FISCAL_YEAR FISCAL_YEAR
    01-APR-2013 31-MAR-2014
    SQL> SY.

  • Error in comparision of year part of date in  writting query

    i am writing a Stored procedure in which i have to compare year
    part from system date to that of a table column in which of date type this my requirement
    this is only a part of my stored procedure
    set serveroutput on
    declare
    p_RN varchar(10);
    begin
    Select Cast(NVL(Count(Patientid),0) as Nvarchar2(10))
    into p_RN from Patient where (TempPatFlag=0 or temppatflag is NULL)
    and *( select extract (year from Registration_Date) from Patient;) = (select extract ( year from sysdate ) from dual;);* -- this is where i have compared year
    end;
    but if i run this below query runs fine
    select extract ( year from sysdate ) from dual;

    Hi,
    This is basically the same idea Hoek posted, I don't think either is significantly faster than the other, but you may find some things clearer in one than in the other:
      select cast(nvl(count(patientid),0) as nvarchar2(10))
      into   p_rn
      from   patient
      where  NVL (temppatflag, 0)              = 0
      and    TRUNC (registration_date, 'YEAR') = TRUNC (sysdate, 'YEAR');You don't need the dual table very much in PL/SQL. For this job, you wouldn't need dual in pure SQL, either.

  • Can i get an exact part of data from select statement

    hi...good afternoon...
    i want to fetch the records from a table by select statement. but i dont want to fetch the as it is record. i want to fetch a particular part of eacg record in that column.
    for example..
    table_name=tab1
    column_name=col1
    the col1 contains datas like *'customer search-cs', 'get customer-gc', 'customer delete-cd'* etc etc..
    now while writing the select query, i want to get the descriptive output as get customer, customer search, customer delete....that is i dont want the symbols..
    is it possible to get this???
    plss suggest...

    You mean like these possible ways of doing it...
    SQL> ed
    Wrote file afiedt.buf
      1* select substr('customer search-cs',1,length('customer search-cs')-3) from dual
    SQL> /
    SUBSTR('CUSTOME
    customer search
    SQL> ed
    Wrote file afiedt.buf
      1* select regexp_substr('customer search-cs','^[^-]*') from dual
    SQL> /
    REGEXP_SUBSTR('
    customer search
    SQL>

  • Extract month part from date

    hi,
    I have a query in Informix which get the month part of a date. Please help me in converting the same to oracle.
    Informix query
    select month(col1 - today) from tab1;
    col1 is a date field, today will yield the current date and month function will get the month of the date.
    In oracle, when we subtract two dates we will get a number value, how to convert that back to date and extract the month part.
    Help me?????
    Regards,
    Gopu

    If your looking for the number of months between two dates:
    SQL> select months_between(sysdate, trunc(sysdate,'yyyy')) from dual ;
    MONTHS_BETWEEN(SYSDATE,TRUNC(SYSDATE,'YYYY'))
    6.06223081
    Just replace my usage of sysdate (etc) with the dates your using...
    Hope that helped,
    Stan

Maybe you are looking for

  • VOICE MEMOS ARE GONE

    hello, i have iphone 5s with software virsion 7.0.6 i plugged the iphone into itunes latest virsion (11.1.5) on my laptop to get to voice memos and transferre them to my desktop, i syncronized the iphone many times and i could see the voice memos and

  • Ipod 4g touch is not recognized by computer and wont turn on or restore

    I bought and ipod touch off a friend because he had drained the battery and forgot his passcode. I charged it in my car and he entered the wrong passcode too many times so it said ipod disabled connect to itunes. And then it shut off. I have not been

  • How reduce envelope header?

    How do you reduce the header margin for envelopes in Pages 5.5 on iOS 10.10?

  • DVI-HDMI Is IT HD?

    I am connecting my MBP to a 42" HDTV via HDMI Will this be Standard Definition High Def 720 1080?? Any ideas? As i wish to play around with high def video and photography work. Thanks

  • Broken BB and I need my PIN to fix it but I can't access my BB to get my PIN!

    Hi  I've been searching for a solution and can't find one that doesn't involve checking my actual BB device. The story is my BB has flagged up a message: "Reload Software 552" BUT to do this on the device manager I need my PIN but I can't find a way