SQL QUERY How to write a sql query with a complex where clause.

I would like to get a list of all my invoices from the past year plus any open invoices that are more than a year old.
I don't want any overlapping rows.
Debra has a question

Debra,
Sorry but you have posted to a forum that deals exclusively with questions/issues about customizing and programming Microsoft Project, a planning and scheduling application. I suggest you delete this post and find a more appropriate forum.
John

Similar Messages

  • How to write a java function for use in where clause in SQL statement

    Hi,
    Does anyone know a good tutorial on how to write and include a Java class/function into Oracle.
    I'd like to write mathematical function to use in my queries, but the resources available in PL/SQL are very limited.
    Many thanx

    Pim,
    I see you got an answer in the PL/SQL forum.
    But in case you haven't seen it, perhaps this Web page will help:
    http://www.oracle.com/technology/tech/java/jsp/index.html
    Good Luck,
    Avi.

  • How to write a sql query to retrieve data entered in the past 2 weeks

    Hi,
    I have file names and last accessed date(java.sql.Date format) stored in my database table, I would like to know how I can write a query to get the name of files accessed in the past 2 weeks,I use open sql server at the back end.
    Thanks in advance.

    This has essentially nothing to do with JDBC. JDBC is just an API to execute the SQL language using Java and thus interact with the databases.
    Your problem is related to the SQL language, you don't know how to write the SQL language. I suggest you to go through a SQL tutorial (there is one at w3schools.com) and to read the SQL documentation which come along with the database in question. A decent database manfacturer has a website and probably also a discussion forum / mailinglist as well.
    I'll give you a hint: you can just use equality operators in SQL like everywhere. For example: "WHERE date < somedate".

  • How to write a SQL query in SAP B1 2007 B with input parameters?

    How to write a SQL query in SAP B1 2007 B with input parameters, on execution of which will ask for some input value from the user and the values will be selected from a list such as item list?

    The syntax like
    SELECT * FROM OITM T0 WHERE T0.ItemCode = '[%0\]'
    Thanks,
    Gordon

  • How to write the sql statement of my finder function in cmp?

    hi,
    I create a cmp ejb from table INFOCOLUMN,and I create a my finder function ,which sql statement is :
    select * from INFOCOLUMN WHERE employee_id=id
    employee_id is a column of the table,and id is the finder function parameter.
    The error is : invalid column name
    So,how to write the sql statement.
    Thanks .

    Mole-
    Bind variables are of the form $1, $2, etc., so your query stmt should look like:
    select * from INFOCOLUMN WHERE employee_id=$1
    -Jon

  • How to write the given query using 'ANY ' operator

    Hi,
    How to write the given query using 'ANY ' operator , I dont need to fetch to grade_master table twice in database, just need to fetch within the result set.
    SELECT dsg_code,dsg_name,dsg_grade FROM designation_master WHERE dsg_orgn='&&Orgn' and dsg_ctry='&&ctry'
    And dsg_loc ='&&loc' And dsg_oru = '&&oru' and dsg_grade in decode('&&radio_group',
    1, SELECT grd_code FROM grade_master WHERE grd_osm_code in (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&Orgn' and grd_ctry='&&ctry' And grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade'),
    2, SELECT grd_code FROM grade_master WHERE grd_osm_code > (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' and grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code),
    3, SELECT grd_code FROM grade_master WHERE grd_osm_code < (Select grd_osm_code FROM grade_master WHERE grd_orgn='&&orgn' and grd_ctry='&&ctry' And grd_loc ='&&loc' And grd_oru = '&&oru' and grd_code ='&&emp_grade'))
    thanks
    rincy

    Hi,
    One thing I understood my your issue is you want to perform, execution of query once or fetch the results sets my minimizing the number of times executions of queries. It would be hard for us to check in this way, atleast provide some temporary data and some business rules. Only I can IN, >, < (queries logical conditons on inner query)
    - Pavan Kumar N
    - ORACLE OCP - 9i/10g
    https://www.oracleinternals.blogspot.com

  • Define a Standalone Download Integrator with an Additional Where clause - SQL error

    Hi,
    I am trying to create a standalone integrator with an Additional Where clause. Followed the steps mentioned in the metalink note 360105.1. When I run the integrator, I get the following error message.
    Please resolve the following error to continue.
    SQL error: ORA-00936: missing expression occurred
    processing stored SQL for Content 20007:GENERAL_441_CNT.
    When I look at the log file, here is what I can see:
    10/22/14 10:50 AM AJPRequestHandler-HTTPThreadGroup-15 TRACE          BneHrSQLControl - SQL:SELECT  FROM PER_PEOPLE_V where last_name=$PARAM$.last_name
    10/22/14 10:50 AM AJPRequestHandler-HTTPThreadGroup-15 TRACE          validateSQLStatement value of sqlStatement is: SELECT  FROM PER_PEOPLE_V where last_name=:RSQLP1
    10/22/14 10:50 AM AJPRequestHandler-HTTPThreadGroup-15 DETAIL         BneHrSQLControl.validateSQLStatement() paramName: last_name
    10/22/14 10:50 AM AJPRequestHandler-HTTPThreadGroup-15 DETAIL         BneHrSQLControl.validateSQLStatement() error in SQL: java.sql.SQLSyntaxErrorException: ORA-00936: missing expression
    So, clearly, the SQL statement that is getting built internally is wrong. Ideally, I would expect the statement to be something like this:
    SELECT *  FROM PER_PEOPLE_V where last_name=$PARAM$.last_name.
    RDBMS : 11.2.0.3.0
    Oracle Applications : 12.1.3
    Any pointers towards the resolution of the issue would be of great help.
    Thanks in Advance!
    Lalitha.

    This is a duplicate post of your other question:  create trigger automatic
    DO NOT start duplicate threads for the same question.
    Locking this thread

  • How to write export dump commad with no datable data only table structure.

    How to write export dump commad with no datable data only table structure will there and command for hole schma.
    e.g. export dump command for scott schema and all table within scott schema in it no table data should be exported.

    If I understand the question, it sounds like you just need to add the flag "ROWS=N" to your export command (I assume that you're talking about the old export utility, not the Data Pump version).
    Justin

  • How to write this sql query in php code ?

    for example:
    insert into temp
    select *
    from testtable;
    after this, i will query data from sql below:
    select *
    from temp;
    how to write this php code ?
    who can help me ?
    thanks!

    Have a look at the manual to find out how to issue queries.
    http://us3.php.net/oci8

  • How to write this SQL query

    We have a table, the structure as below: (I put a blank row in the middle to make it clear)
    Product_ID     Retailer     Retail_Price
    1001          A          1.2
    1001          B          1.5
    1001          C          1.4
    1002          B          2.0
    1002          C          2.1
    1002          E          1.8
    1002          F          2.0
    1003          A          1.7
    1003          C          1.5
    Basically we use the table to compare the retail price for different retailers in terms of different products. My customer asked me to give a report based on above table but only shows the retail prices which contain retailer A.
    For example, on above table I need to give a report like below:
    Product_ID     Retailer     Retail_Price
    1001          A          1.2
    1001          B          1.5
    1001          C          1.4
    1003          A          1.7
    1003          C          1.5
    Can anybody give some ideas on how I should write a SQL to achieve this.
    Many thanks!

    SQL> create table product(
    2 Product_ID varchar2(10),
    3 Retailer varchar2(10),
    4 Retail_Price number(7,2)
    5 )
    6 /
    Table created.
    SQL> insert into product values('1001','A',1.2)
    2 /
    1 row created.
    SQL> insert into product values('1001','B',1.5)
    2 /
    1 row created.
    SQL> insert into product values('1001','C',1.4)
    2 /
    1 row created.
    SQL> insert into product values('1002','B',2.0)
    2 /
    1 row created.
    SQL> insert into product values('1002','C',2.1)
    2 /
    1 row created.
    SQL> insert into product values('1002','E',1.8)
    2 /
    1 row created.
    SQL> insert into product values('1002','F',2.0)
    2 /
    1 row created.
    SQL> insert into product values('1003','A',1.7)
    2 /
    1 row created.
    SQL> insert into product values('1003','C',1.5)
    2 /
    1 row created.
    SQL> select * from product
    2 /
    PRODUCT_ID RETAILER RETAIL_PRICE
    1001 A 1.2
    1001 B 1.5
    1001 C 1.4
    1002 B 2
    1002 C 2.1
    1002 E 1.8
    1002 F 2
    1003 A 1.7
    1003 C 1.5
    9 rows selected.
    SQL> select * from product where PRODUCT_ID in (
    2 select distinct PRODUCT_ID from product where RETAILER='A')
    3 /
    PRODUCT_ID RETAILER RETAIL_PRICE
    1001 A 1.2
    1001 B 1.5
    1001 C 1.4
    1003 A 1.7
    1003 C 1.5

  • How to write this sql code ?

    for example below shows:
    create table temp
    order_type varchar2(30),
    order_num number);
    insert into temp values('apple',000001);
    insert into temp values('banana',000002);
    insert into temp values('chair',000003);
    select *
    from temp
    where instr(order_type,decode(x,1,'a',2,'b',2,'c',order_type)) >0
    if i let x equals 2 and i want to get b and c from above querying .
    why above query could not get 'c' and only get 'b' if i give 2 to x ?
    how to write above select clause ?
    who can help me ?
    thanks!

    Decode will return the first match;
    SQL> select decode(2,1,'a',2,'b',2,'c')
    from dual
    D
    b
    1 row selected.This may help;
    old: select *
    from temp
    where regexp_like(order_type, case to_number(&x)
                                     when 1 then 'a'
                                     when 2 then 'b|c'
                                  end)
    new: select *
    from temp
    where regexp_like(order_type, case to_number(2)
                                     when 1 then 'a'
                                     when 2 then 'b|c'
                                  end)
    ORDER_TYPE                      ORDER_NUM
    banana                                  2
    chair                                   3
    2 rows selected.

  • How to write XSJS Select Query with input parameters

    Hello Experts,
    I am creating a xsjs file and in that file I am trying to write a Select Query based on a Calculation View
    I have tried it the following way:
    var query = 'SELECT TOP 100 \"Name\", \"Address\", \"City\", \"Country\" FROM \"_SYS_BIC\".\"Test.HL/AddressView\"'
        + 'WITH PARAMETERS(\'PLACEHOLDER\' = (\'$$P_Name$$\', \' Akhil \'),'
      + '\'PLACEHOLDER\' = (\'$$P_City$$\', \' Lucknow \'))';
    But it gives me the "Mixed spaces and tabs error".
    How should I write XSJS Select Query with input parameters?
    Regards,
    Rohit

    >But it gives me the "Mixed spaces and tabs error".
    Mixed spaces and tabs has nothing to do with the syntax of the statement. You used both spaces and the tab in the content - which JSLint doesn't like.  Remove the beginning spaces of each line and use only one or the other.
    The actual syntax of your statement doesn't look right.  The problem is that you are escaping the \ when you don't need to if you are using ' instead of " for your string.  You escape with \" in the first line but then escape with \' in the 2nd and 3rd line.  That is going to cause serious parsing problems with the command.

  • How to write PL SQL function?

    First of all, whenever i try and put my attempted code for this in a thread it says 'sorry content not allowed'. I have attempted to make the function but i keep getting errors. I think its because my logic is wrong anyway. I am not quite sure how to do it.
    I am a student and this is the first time i have been asked to write a function, i have almost no prior knowledge so please bare with me.
    Could people give me some ideas where to start. It seems i cant even get a simple function to work at the moment! Where is it best to write and test the function? I have been using SQL commands, should i use Script creator instead?
    Any help or feedback would be great.
    Thanks in advance!
    Edited by: Jay on 08-Dec-2010 03:09

    Hi,
    Here's a simple function, and a test of it:
    CREATE OR REPLACE FUNCTION hello
    (     in_txt          IN     VARCHAR2
    RETURN     VARCHAR2
    DETERMINISTIC
    IS
         return_txt     VARCHAR2 (100);     -- Value to be returned
    BEGIN
         return_txt := 'Hello, '
                 || in_txt
                 || '!';
         RETURN     return_txt;
    END     hello
    SHOW ERRORS
    SELECT     dname
    ,     hello (dname)     AS hello_results
    FROM     scott.dept
    ;Output:
    Function created.
    No errors.
    DNAME          HELLO_RESULTS
    ACCOUNTING     Hello, ACCOUNTING!
    RESEARCH       Hello, RESEARCH!
    SALES          Hello, SALES!
    OPERATIONS     Hello, OPERATIONS!I don't know why you can't post your function. Here's how you can find out:
    First, change the subject line of your first message to something like "IN PROGRESS - Please Do Not Reply Yet".
    Copy the hello function I posted into your text editor
    Reply to this message, and post your copy of the function.
    Did you get the error again? If so, it looks like there's some security feature on your system that's keeping you from posting code.
    If you can post my function exactly as it is, then change it a little. Update your latest message, a little bit at a time, to make the function more and more like your function. For example, just change the name of the function to your actual function name. Change the message. If it posts corretly, make another small change, until you get the "content not allowed" message. If you can't figure out what's causing it, then change the subject line back to something meaningful, change the last message back to the last version that did post correctly, and describe what you changed that caused the error.
    You can use SQL*Plus to create and test the function. Write a script (that is, a text file), similar to the one I posted above. If you name the file hello.sql, then you can run the script from the "SQL> " prompt by saying
    @c:\fubar\sql\hellousing the full path name on your system where I used "c:\fubar\sql" above.
    Edited by: Frank Kulash on Dec 8, 2010 9:18 AM

  • How to write data from query into Real time cube?

    Hi All,
    Can anyone explain me step by step how to write data into a real time cube from front end queries.
    Thanks in advance

    Hi
    You can do this using Integrated Planning
    You need to create a aggregation level on the Real Time infocube and can create Planning function/sequence, Variables if needed.
    Then you can create query on this aggregation level and you can make the keyfigures Input ready in property pane and you can change the data and save it into cube.
    Please find below help link which clearly explains step by step about Integrated Planning like creating input ready queries etc.,
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/43/0c033316cd2bc4e10000000a114cbd/frameset.htm
    Regards
    Ravi

  • How to write a  SQL based on a  view can get the best performance ?

    Hi ,
        I am thinking about performance of  sql based on VIEW .<b>For the best performance ,How to do when I create  and use a view ?</b>  for example , Should i use key in my where clause as select data from table?  (of cause ,this key refers to the key of table which structure the view. ) , <b>Could you give me any advice on creating and using view in term of performance</b> ?

    Hi Guixin Chen,
    Performance depends on various factors. The major key factors are:
    1.  Result Set should be Small
    2.  Amount of Data Transferred should be minimum.
    3.  Number of Data Transfers should be minimum.
    4.  Search Overhead should be minimum.
    5.  Database Load should be minimum.
    For more details, check the following docs.
    <b>Performance Notes</b>
    http://help.sap.com/saphelp_nw04s/helpdata/en/fc/eb3b7e358411d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/5b/320c40ac368f5ce10000000a155106/frameset.htm
    You can also check Performance by,
    1.  Transaction code ST05
    2.   From ABAP Workbench using the menu path Test Performance Trace.
    Dont forget to reward pts, if it helps ;>)
    Regards,
    Rakesh.

Maybe you are looking for

  • Log on to Runtime Workbench : click display error on page

    Dear all, when i try to log on to Runtime Workbench  and click on display message , i am getting error that error on page, we have already done post implementation steps for PI(XI),, what to do, to test the senario from Runtime Workbench. Best regard

  • Best export solution for windows clients

    Hi, I need to regularly make files playable & editable on windows machines of all different specs/os versions for various clients. I've been going to AVI at DV PAL codec, using MPEG Streamclip (cos I like the batch processing), but I've recently star

  • Problem in FBL1n tx

    Hi All,        When I am running FBL1n tx and seeing all items for 1st quarter, I am not able to see the correct G/L account no and am seeing empty cost center. When I check the related PO I can view the correct G/L account and cost center.         W

  • Printer Error server-error-service-unavailable

    Im currently getting the errpr msg server-error-service-unavailable when im trying to connect to a printer. I have found out how to over come this problem by resetting the printer. Reset Printing System feature, follow these steps: In the Finder, cho

  • New MDC, XI Issue

    Hi, 2 things: 1) I am trying to connect a first IDES client to the MDS for checking Extraction capabilities. I was following instructions ConfigGuide Harmonization+Central MDM, page 23 and fell about some pain-points. I downloaded MDM Content on the