Get age from DOB query problem

Hi I'm a bit of a noob. I've found this query and got it to work but I want to find all the people over the age of 30. How do I go about doing this?
SELECT FLOOR( MONTHS_BETWEEN( CURRENT_DATE, DOB ) / 12 ) AS person_age FROM Customer
This shows everyones age.
Many thanks

It's working fine
This is example to illustrate find age which are greater than 25.
SQL> select *
2 from (
3 SELECT FLOOR( MONTHS_BETWEEN( CURRENT_DATE, hiredate ) / 12 ) AS person_age
4 FROM emp
5 )
6 where person_age > 25
7 /
PERSON_AGE
27
27
27
27
27
27
27
27
27
27
27
PERSON_AGE
26
12 rows selected.
Actual requirement is as follows:
SQL> select *
2 from (
3 SELECT FLOOR( MONTHS_BETWEEN( CURRENT_DATE, hiredate ) / 12 ) AS person_age
4 FROM emp
5 )
6 where person_age > 30
7 /
Edited by: venkata on Dec 15, 2008 11:02 AM

Similar Messages

  • How to get key from MDX Query

    Hi All,
    how to get key from mdx query ?
    example :
    SELECT [Measures].[67822GFASOU7KUT6FKHSQ34FV] ON COLUMNS NON EMPTY CROSSJOIN([ZCOMPANY].MEMBERS, [ZMILL].MEMBERS) ON ROWS FROM ZODS_GL/ZODS_GL_001
    the result from this mdx query are zcompany text and zmill text, how to get company key and mill key ?
    Regards
    JeiMing

    hi Jeiming,
    to get key in mdx, you can try something like
    [ZCOMPANY].[LEVEL01].MEMBERS
    properties [ZCOMPANY].[2ZCOMPANY]
    following threads may useful
    Extracting texts with MDX
    MDX Statement - display only keys for characterstics and their dis. attrib.
    hope this helps.

  • Bapi to get data from BW query

    Hi,
    Does anyone familiar with bapi function to get data from BW query .???
    I'm trying to use  RS_VC_GET_QUERY_VIEW_DATA_FLAT  but i get only the SUM rows of the query
    and not the details rows (drill down).
    i want to export the data of BW query to table and i need all the query data.
    if someone have an example or documention its will be great.
    Thanks.

    Hi,
    Does anyone familiar with bapi function to get data from BW query .???
    I'm trying to use  RS_VC_GET_QUERY_VIEW_DATA_FLAT  but i get only the SUM rows of the query
    and not the details rows (drill down).
    i want to export the data of BW query to table and i need all the query data.
    if someone have an example or documention its will be great.
    Thanks.

  • KEY-EXEQRY trigger and FROM CLAUSE QUERY problem

    Hi,
    I have a form designed in Oracle Forms6i. I have two block on it, BlockA and BlockB.
    When BlockA is queried with some data to search, I need to build the FROM CLAUSE QUERY for BlockB. It uses the same WHERE condition as I used to search BlockA.
    I am building the FROM CLAUSE QUERY and executing query for BlockB on KEY-EXEQRY trigger of BlockA.
    It works fine, if first time, I query the BlockA without any specific data. But it gives me error 'ORA-01008: not all variables bound' if I query the BlockA with specific data very first time.
    Please advise.
    Thanx
    Zaaf

    No, I am not using any substitution variables. To get the LAST_QUERY for BlockA, I am using Get_Block_Property.
    But now I switched it to :system.LAST_QUERY and it worked.
    Thank you!

  • How to get values from a query string in URL in a jsf page?

    if i have a url, http://my.com/?name=john+smith, how do i get the values from that url in a jsf page and then pass those values to a servlet?
    i know how to do that in jsp using "request.getParamter("name")" and save it in a bean and then forward to a servlet. But what about in jsf?

    Hello,
    Try this:
    Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
    String name = (String) requestMap.get("name");If isn't worked one of these methods probably will solve your problem.
    FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
    FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderMap();hth.

  • Getting file from ftp server problem.

    Anyone can tell me what's wrong with my code.
    I try to get Test.txt from my ftp server with this coding :
    public class FTPClient{
    public static final void main(String[] args) throws Exception
    {   try {
    URL url = new URL("ftp://user:password@myhost:21/MyFiles/Test.txt");
    URLConnection c = url.openConnection();
    BufferedReader r = new BufferedReader(new InputStreamReader(c.getInputStream()));
    String l = null;
    while ( (l = r.readLine()) != null)
    System.out.println(l);
    catch (Exception e)
    System.out.println("Uh oh, got an IOException error!");
    e.printStackTrace();
    But i get the following error :
    sun.net.ftp.FtpProtocolException: PORT :
    at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:435)
    at sun.net.ftp.FtpClient.get(FtpClient.java:550)
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:382)
    at FTPClient.main(FTPClient.java:8)
    Can somebody help me,
    What's worng with my coding..?
    Thanks,

    I delete the :21 from my code but the same error occured.
    I also try this code
    FtpClient ftpClient = new FtpClient();
    String host ="10.10.10.237";
    String username="username";
    String password="password";
    try
    ftpClient.openServer(host); // connect to FTP server
    ftpClient.login(username, password); // login
    ftpClient.cd("TestFTP");
    ftpClient.binary();
    InputStream is = ftpClient.get("Test.txt");
    ftpClient.closeServer(); //close connectionand I got the same error
    sun.net.ftp.FtpProtocolException: PORT :
    at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:435)
    at sun.net.ftp.FtpClient.get(FtpClient.java:550)
    at Client.main(Client.java:19)
    I dont know what is the problem.. I've try to find information about this error on the net, but cannot find anything that can help me...

  • SQL- Getting Subtotal From a Query

    Hi,
    I need to run a query where I can get a subtotal for each items in a table.  The query should produce something like:
    3 apple
    4 grape
    1 orange
    I did a SUM and COUNT function but, I get the total records (8) in the table instead of the subtotals.
    SELECT      id, SUM(fruit) AS Total
    FROM         table
    WHERE     ORDER BY fruit
    Any suggestions would be great.
    Thanks,
    Jenn

    try this
    SELECT     fruit,count(*) as fruit_count, SUM(fruit) AS Total
    FROM         table
    WHERE     group BY fruit

  • Get data from bw query to r/3

    Hi,
    There is a query defined in BW with some variables. The current process is user is executing the query with necessary variables and the query result output is saving as csv file and this file is used in r3 to update the data in r3.
    Now we have to make this process automate. We have to get the query result data from BW to R3.
    We have a constraint of not using the Open hub method in BW.
    Is there any function module or any standard program to get the query result data from BW to r3.
    Any help is highly appreicated.

    able to resolve the issue..
    creating trusting RFC connection solved the problem

  • Use APD to get Rank from TopN query result to target for Universe

    Hello,
    I am trying to take a query result set where I am calculating a key figure as Rank and run it through an APD to write to a DSO.
    This is a top 5 query for a dashboard.  I keep getting an MDX failure on the query.
    Any ideas? 
    My ultimate goal is to set up a process to take TopN query results and get them into a target that can be used in a Universe.
    Thanks,
    Chris

    Hello Chris,
    I recommend to post this query to the [Universe Designer and Business Views Designer|Semantic Layer; forum.
    This forum is dedicated to topics related to the universes and business views.
    It is monitored by qualified technicians and you will get a faster response there.
    Also, all Enterprise Information Management queries remain in one place and thus can be easily searched in one place.
    Thanks a lot,
    Falk

  • How to get fieldnames from Select * query ?

    How can I get the fieldnames returned with a SELECT * query ?
    When I use GetFieldName or GetFieldOriginalName I only get fieldnames of "*".

    You should use the fields collection, in the OraDynaset object.
    All you need to do is :
    for i = 0 to Recordset.Fields.Count -1
    debug.print Recordset.Fields(i).name
    debug.print Recordset.Fields(i).OriginalName 'this will print the field's name before an alias
    next i

  • From Clause Query problem

    The query should fetch 2 rows for this item.
    but instead fetching no rows
    SELECT B.JOB_CODE, A.CLASSIFICATION_CODE, A.ITEM_ABBR,
    A.ITEM_DESC, A.ALT_ITEM_CODE, A.UOM_DESC,
    A.BASIC_PRICE, (A.OPENING_QTY + (NVL(B.ACC_QTY, 0)
    + NVL(F.RET_IN, 0)) - (NVL(C.ISS_QTY, 0) + NVL(G.RET_OUT,
    0))) AS OPENING_STOCK, (NVL(D.ACC_QTY, 0)
    + NVL(H.RET_IN, 0)) RECEIVED, (NVL(E.ISS_QTY, 0)
    + NVL(I.RET_OUT, 0)) ISSUED,
    ((A.OPENING_QTY + (NVL(B.ACC_QTY, 0) + NVL(F.RET_IN, 0))
    - (NVL(C.ISS_QTY, 0) + NVL(G.RET_OUT, 0)))
    + (NVL(D.ACC_QTY, 0) + NVL(H.RET_IN, 0)) - (NVL(E.ISS_QTY,
    0) + NVL(I.RET_OUT, 0))) QTY_IN_HAND
    FROM (SELECT CLASSIFICATION_CODE, ITEM_ABBR, ITEM_DESC,
    ALT_ITEM_CODE, UOM_MASTER.UOM_DESC,
    BASIC_PRICE, 0 OPENING_QTY
    FROM ITEM_MASTER, UOM_MASTER
    WHERE ITEM_MASTER.UOM_CODE = UOM_MASTER.UOM_CODE)
    A,
    (SELECT GRN_HEADER.JOB_CODE,
    GRN_DETAIL.ITEM_CODE,
    SUM(NVL(GRN_DETAIL.ACCEPT_QTY, 0))
    ACC_QTY
    FROM GRN_HEADER, GRN_DETAIL
    WHERE GRN_HEADER.GRN_NO = GRN_DETAIL.GRN_NO AND
    GRN_HEADER.GRN_DATE < '01-JAN-2006'
    GROUP BY GRN_HEADER.JOB_CODE,
    GRN_DETAIL.ITEM_CODE) B,
    (SELECT B.TO_JOB_CODE, B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_IN
    FROM MATERIAL_MOVEMENT_HEADER A,
    MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE < '01-JAN-2006'
    GROUP BY B.TO_JOB_CODE, B.ITEM_CODE) F,
    (SELECT MRN_HEADER.JOB_CODE,
    MRN_DETAIL.ITEM_CODE,
    SUM(NVL(MRN_DETAIL.ISSUED_QTY, 0))
    ISS_QTY
    FROM MRN_HEADER, MRN_DETAIL
    WHERE MRN_HEADER.MRN_NO = MRN_DETAIL.MRN_NO AND
    MRN_HEADER.MRN_DATE < '01-JAN-2006'
    GROUP BY MRN_HEADER.JOB_CODE,
    MRN_DETAIL.ITEM_CODE) C,
    (SELECT B.JOB_CODE, B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_OUT
    FROM MATERIAL_MOVEMENT_HEADER A,
    MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE < '01-JAN-2006'
    GROUP BY B.JOB_CODE, B.ITEM_CODE) G,
    (SELECT GRN_HEADER.JOB_CODE,
    GRN_DETAIL.ITEM_CODE,
    SUM(NVL(GRN_DETAIL.ACCEPT_QTY, 0))
    ACC_QTY
    FROM GRN_HEADER, GRN_DETAIL
    WHERE GRN_HEADER.GRN_NO = GRN_DETAIL.GRN_NO AND
    GRN_HEADER.GRN_DATE BETWEEN
    '01-JAN-2006' AND '31-DEC-2006'
    GROUP BY GRN_HEADER.JOB_CODE,
    GRN_DETAIL.ITEM_CODE) D,
    (SELECT B.TO_JOB_CODE, B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_IN
    FROM MATERIAL_MOVEMENT_HEADER A,
    MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE BETWEEN '01-JAN-2006' AND
    '31-DEC-2006'
    GROUP BY B.TO_JOB_CODE, B.ITEM_CODE) H,
    (SELECT MRN_HEADER.JOB_CODE,
    MRN_DETAIL.ITEM_CODE,
    SUM(NVL(MRN_DETAIL.ISSUED_QTY, 0))
    ISS_QTY
    FROM MRN_HEADER, MRN_DETAIL
    WHERE MRN_HEADER.MRN_NO = MRN_DETAIL.MRN_NO AND
    MRN_HEADER.MRN_DATE BETWEEN
    '01-JAN-2006' AND '31-DEC-2006'
    GROUP BY MRN_HEADER.JOB_CODE,
    MRN_DETAIL.ITEM_CODE) E,
    (SELECT B.JOB_CODE, B.ITEM_CODE,
    SUM(NVL(B.QUANTITY_ISSUE, 0)) RET_OUT
    FROM MATERIAL_MOVEMENT_HEADER A,
    MATERIAL_MOVEMENT_DETAIL B
    WHERE A.SLIP_NO = B.SLIP_NO AND
    A.SLIP_DATE BETWEEN '01-JAN-2006' AND
    '31-DEC-2006'
    GROUP BY B.JOB_CODE, B.ITEM_CODE) I
    WHERE A.ALT_ITEM_CODE = B.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = C.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = D.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = E.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = F.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = G.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = H.ITEM_CODE (+) AND
    A.ALT_ITEM_CODE = I.ITEM_CODE (+) AND
    B.JOB_CODE = C.JOB_CODE AND
    B.JOB_CODE = D.JOB_CODE AND
    B.JOB_CODE = E.JOB_CODE AND
    B.JOB_CODE = F.TO_JOB_CODE AND
    B.JOB_CODE = G.JOB_CODE AND
    B.JOB_CODE = H.TO_JOB_CODE AND
    B.JOB_CODE = I.JOB_CODE AND
    A.ALT_ITEM_CODE = 'BOSNVL0004-006-002';
    ...

    3 posts...in the same forum?

  • Get XSD from Report Query

    APEX 4.0.2
    Oracle 11.2.0.1.0
    Hello,
    We are trying to retrieve the XML Schema for a Report Query.
    The following code example is working, but the 'xsd' parameter for p_document_format is not documented.
    Is 'xsd' a supported parameter value for APEX_UTIL.GET_PRINT_DOCUMENT?
    v_blob := APEX_UTIL.GET_PRINT_DOCUMENT (
        p_application_id      => NV('APP_ID'),
        p_report_query_name   => 'test',
        p_report_layout_name => null,
        p_report_layout_type => null, 
        p_document_format     => 'xsd',
        p_print_server => null);Thank you in advance!

    Hi Eric,
    We have four different versions of apex_util.get_print_document, so depending on what you want to do, you can create PDFs and other document types based on your own XML data, your own style-sheets, or referencing pre-defined report-queries, with pre-defined layouts, or custom layouts. We support the output formats I've previously listed for all four versions. However the internal implementation of those APIs is different for the APIs that reference report queries and those that reference custom XML data. When referencing report queries, APEX first loads and executes those queries and generates the XML data, and then passes the XML on the the print rendering engine. The parsing and execution of those queries happens to use the same internal functions that are also used on the report query edit page, where you have buttons that allow for downloading XML and XML Schema representations of your report query. Those XML and XSD documents are intended to be used with the BI Publisher Word Plug-In or third-party XSL design tools to design report layouts. Now given that the same internal functions are used, you can actually generate XML Schema (XSD) documents using the apex_util.get_print_document API, but only with those versions that let you reference a pre-defined report query. This isn't officially supported, so I can guarantee that this behavior won't change in the future, though I don't see why we would change that. The main reason for supporting XML in those APIs is really to test the print functionality without requiring a print rendering engine. But looks like there are some other use cases for those output formats as well.
    Hope the helps,
    Regards,
    Marc

  • Help: cant get values from a resultset

    i have a class that contains all my MySQL statement and i am trying to use the results found from one of my select statements to pass on into another class which displays the results in a gui form. Here is my query:
    public void profile(String user)
            try
                 Class.forName(driver);
                 Connection con = DriverManager.getConnection( url,db_user, db_pass);
                 String username, name, email, dob, bio, gender, homepage, number;
                 //find username and select all details
                 String find = "SELECT Username, Full_name, Email, dob, Biography, Gender, Homepage, Contact_number FROM users WHERE Username = ? ";
                 PreparedStatement ps1 = con.prepareStatement(find);
                 ps1.setString(1, user);
                ResultSet rs = ps1.executeQuery();
                while(rs.next())
                    //retreive information from the server
                    username = rs.getString(1);
                    name  = rs.getString(2);
                    email  = rs.getString(3);
                    dob = rs.getString(4);
                    bio = rs.getString(5);
                    gender = rs.getString(6);
                    homepage = rs.getString(7);
                    number = rs.getString(8);
                    User_Profile profile = new User_Profile(username, name, email, dob, bio, gender, homepage, number);
                    JOptionPane.showMessageDialog(null, username + bio + email, null, JOptionPane.ERROR_MESSAGE);
                  con.close();
            catch( Exception e )
                     e.printStackTrace();
                     JOptionPane.showMessageDialog(null, "error," + e.getMessage(), null, JOptionPane.ERROR_MESSAGE);
        }As you can see, i am trying to pass on the variables username, name, etc to a new instance of my user_profile class but it doesnt for some reason. i dont get any comple errors so thats ok. i created messege dialog box from within the while statement above to see if a value is stored, and yes their is a value stored in my variables
    below is the user profile class which shows my constructor that suppose to get the values from the query class in this code entered above       User_Profile profile = new User_Profile(username, name, email, dob, bio, gender, homepage, number);
        protected String username;
        protected String FullName;
        protected String Email;
        protected String DOB;
        protected String Biography;
        protected String Gender;
        protected String Homepage;
        protected String Con_Number;
        protected String crnt_user;
    public User_Profile(String user, String name, String email, String dob,
                                String bio, String gender, String homepage, String number)
            initComponents();
            addWindowListener( this );
            //get values from sql query and store them here.
            this.username = user;
            this.FullName = name;
            this.Email = email;
            this.DOB = dob;
            this.Biography = bio;
            this.Gender = gender;
            this.Homepage = homepage;
            this.Con_Number = number;
         }the code below is used to display one of the values received from the query class, in this case returns null..
    txt_name.setText(username)

    Does the user String match the database String
    exactly?
    Some databases are case sensative.Sorry posted before done.
    Also, ensure you do not have trailing spaces in one or both. I remember Oracle had this problem a few years ago using the Type 4 driver but not through ODBC.

  • Calculate age using DOB

    Is there a way to calculate age from DOB in the RPD business model layer? In the table, there is only DOB stored in string format (e.g. 19700125, YYYYMMDD format) and we need to dervie age in the RPD.

    Here's a hint:
    use TimestampDiff funtction
    such as TimestampDiff (SQL_TSI_YEAR, date1, now() )
    You might have to use CAST function to turn your column into date type....
    I hope this is helpful.

  • Find current age from day in mdx query

    Hi,
    I need to find current age.In my cube i have dob attribute.
    so how can  i find current age from day using mdx query.
    Thanks,
    Indu
    indu

    Hi,
    when i ran above query, i am getting days.
    But i need current age in years.
    so i tried with below query, then i am getting value  like 8.99.how can i round off in mdx query?
    in sql i used Floor function for roundoff. in mdx which function should i use?
    With
    MEMBER [DOB] AS DATEDIFF('d',[Ship Date].[Date].CurrentMember.Name,Now())/365.25
    Select {[DOB]}
    on columns ,
    NON
    EMPTY {[Ship Date].[Date].[Date]}
    ON ROWS From [Adventure Works]
    indu

Maybe you are looking for

  • How to use mirroring with Apple TV

    I want to use mirroring from my macbook pro onto my apple TV but I cannot find the airplay icon/app on either my macbook or my iphone 4S, what do I need to do to get started with mirroring.  I cannot figure this out from the online user guides and di

  • Urgent help in Requisition E-Recruiting.

    Hi, In E-recruiting ,  Requisition information is stored in HRP5125 database table.   But the history of "status" and "Reason_code" is not saved in HRP5125.  Only one status update (last one) per day is getting saved. where the status history is save

  • Safari is not playing .mpg videos while navegating in the web

    I am having problems with the Safari web browser. While navigating the web, if I want to watch a video that has an ".mpg" extension, it will simply open a new window and leave it blank without starting the QuickTime plug in to play the video. I remem

  • Date and timestamp code

    Hi Experts, I've a table which contains date and timestamp in single field. Now I need to do look up on this table. But this table can contain multiple records on same day.  I need to take record which has lower data and timestamp. How can I write a

  • Send IP range

    Hi... i have Cisco 3640 Router and i am using freeRadius with MySQL to send static IP address to my customers. I dont have any problem to give static IP address to customer. Framed-IP-Address', 'A.B.C.20 Framed-IP-Netmask', '255.255.255.0 I would lik