QUERY HELP!!! trying to create a query

i'm creating a summary report
i have a table with sale dates
for example i have a table tab_1 and column saleDate as
saleDat
1923
1936
1945
2003
2005
saleDate contains years and there are some missing years where no sale
was made
My report has to display years starting from earliest year
so i have to create a query that starts with 1923
but the problem is that I have to have years that are not in table.
for example i have to display years 1924 which is not in table
so the part of report has to look like
1923 blah blah summary.........
1924 "
1925
1926
2005
2006
upto current year (2006 may not be in the table, but i have to display)
i just need to know the query that can query all the years starting from
the ealiest saleDate to current year
thanks in advance

Please write the query in the following form:
SELECT a.year, --- place other columns from your table.
FROM (SELECT (:start_num + rownum) year
FROM all_tab_columns
WHERE :start_num + rownum <= :end_num) a,
tab_1 b
WHERE a.year = b.saleDat(+);
Note:
1) if your start year and end year are 1923 and 2006. Then input as below:
:start_num = 1922
:end_num = 2006
2) Since for some of the years (1924 etc) may not be there in your so you may need to use NVL to print proper indicators.
3) If you have more than one record in tab_1 for a particular year then group them based year and then use it.
Hope this helps.
- Saumen.

Similar Messages

  • Help need to create a query

    I need to fetch records from a table. Please help me to create a query
    The Tablename is Employee. It has the following records
    Department Empname Gender
    Finance Tom Male
    Finance Rick Male
    Finance Stacy Female
    Corporate Tom Male
    Corporate Rob Male
    I want to select the value of the Gender field from the Employee table corresponding to a Department
    If all the values in the Gender field are 'MALE' corresponding to 'finance' in the Department field, the value should be 'MALE'
    If there is a value 'FEMALE', the gender corresponding to the Empname 'TOM' should be considered as the gender

    Tables have rows - not records.
    Your question is a basic SQL language question - which means you do not know the SQL language. This forum is not a classroom for teaching you the SQL language.
    Use the following as the basic outline of how your SQL language statement need to look like for selecting the required from the table:
    SELECT
      <<sql projection goes here>>
    FROM <<table name goes here>>
    WHERE <<filter conditions go here>>
    {code}
    The SQL projection specifies the list of columns the SQL need to return to the caller.
    The filter condition is basic predicates and AND and OR  can be used for multiple predicates.
    Go to http://tahiti.oracle.com and look for the +SQL Reference Guide+ for the Oracle version you are using. The +SELECT+ statement syntax is covered in detail and sample statements are provided.
    And please do not expect this forum to be used as a classroom, or expect this forum to do your homework for a class.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Help: How to create a query like this?

    I am working on a report and I am facing on a question like this:
    TABLE TEST has two columns A and B
    A B
    2 INFO21
    2 INFO22
    3 INFO31
    3 INFO32
    3 INFO33
    I'd like to create a query which will return
    A INFO
    2 INFO21, INFO22
    3 INFO31, INFO32, INFO33
    Please help.
    Thank you in advance
    Jimmy

    A lot of pretty fine examples here:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    Rgds.

  • Help: How to create a query that transpose the column content?

    Here, suppose that I have two tables
    TAB_A:
    ID     TYPE
    1     AA
    1     AB
    1     AC
    2     BA
    2     BB
    2     BC
    2     BD
    I'd like to create a query that gives result as:
    ID     TYPE
    1     AA AB AC
    2     BA BB BC BD Any suggestions?
    Thank you in advance.
    Jimmy

    Hi
    Try this:
    SELECT id,
    replace(LTRIM(MAX(SYS_CONNECT_BY_PATH(type,'*'))
    KEEP (DENSE_RANK LAST ORDER BY curr),'*'),'*', ', ') AS type
    FROM (SELECT id, type,
    ROW_NUMBER() OVER (PARTITION BY id ORDER BY type) AS curr,
    ROW_NUMBER() OVER (PARTITION BY id ORDER BY type) -1 AS prev
    FROM tab_a)
    GROUP BY id
    CONNECT BY prev = PRIOR curr AND id = PRIOR id
    START WITH curr = 1;
    Ott Karesz
    http://www.trendo-kft.hu

  • Error message when trying to create any query

     
    I am trying to run a query on my sql server and get the following error message:
    "An error occurred while executing batch. Error message is: The directory name is invalid."
    how do I fix?

    With me it had indeed something todo with some temp files.
    Me and my colleague where logged on to a remote server (remote desktop connection), and on that server we were both using the sql management studio.
    Suddenly we both received the error "An error occurred while executing batch. Error message is: The directory name is invalid.".
    The solution for us was just logging out (ALL USERS) that were currently connected (with a remote desktop connection and that were working with the sql management studio) and afterwards logging back in. That solved it here.
    Regards
    Thomas

  • Help trying to create a button in safari please.

    trying to create a button that runs an applescript. I have been discussing it in 101 but cross posting it here because it's not getting much interest over there.
    Any help would be nice. I have read Become an xCoder and it doesn't seem to answer my questions.
    http://discussions.apple.com/thread.jspa?threadID=1514799&tstart=0

    Is there no way to create an appcontroller that works like an applescript? Or get an applescript to be recognized so a new NSButton added to the Bookmark bar be activated?
    i.e.
    *tell application "System Events"*
    * tell application "Safari" to activate*
    * keystroke "n" using {command down}*
    * delay 0.1*
    * keystroke "l" using {command down, shift down}*
    *end tell*
    Or,
    _Something Like:_
    / AppController /
    *#import <Cocoa/Cocoa.h>*
    *@interface AppController : NSObject*
    *IBOutlet id NSButton;*
    *-(IBAction) autoFill:,delay 0.1,checkSpelling:(id)sender*
    @end
    I really don't know if that AppController looks anything like it should or if it's even close.

  • Help trying to create multiple rectangles

    Hi, I'm trying to create a five-in-a-row game, and I need lots of rectangles, forming a kind of a net. I've figured out a bit, but the thing is that every new rectangle seems to erase all the former ones, so in the end there's just the last one. I use this code:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    public class luffare extends JApplet {
    ruta rutor[] = new ruta[400];
    public void init() {
    for(int a=0;a<20;a++){
    for(int b=0;b<20;b++){
         rutor[a*20+b] = new ruta(a*10, b*10);
         //rutor[a*20+b].setBackground(Color.white);
    getContentPane().add(rutor[a*20+b]);
    class ruta extends JPanel implements MouseListener, MouseMotionListener{
    Rectangle rect;
    public ruta(int xPos, int yPos){
    rect = new Rectangle(xPos, yPos, 10, 10);
    addMouseMotionListener(this);
    addMouseListener(this);
    public void paintComponent(Graphics g){
    Graphics2D g2 = (Graphics2D)g;
    g2.draw(rect);
    public void mouseReleased(MouseEvent e){}
    public void mousePressed(MouseEvent e){}
    public void mouseDragged(MouseEvent e){}
    public void mouseMoved(MouseEvent e){}
    public void mouseClicked(MouseEvent e){}
    public void mouseExited(MouseEvent e){}
    public void mouseEntered(MouseEvent e){}
    I'm really stuck here, can anybody help?
    regards,
    M?ns Wide

    Hey, I'm no Swing expert, actually I'm very much a beginner in Swing! I suggest you go through the Swing tutorials
    {color:#0000ff}http://java.sun.com/docs/books/tutorial/uiswing/index.html{color}
    and learn about the multitude of features that can be useful to you.
    After that, if you have any problems related to Swing, please post in the Swing forum where you will get advice from real experts.
    This works, using setBounds(...) with null Layout --I've added the position number to each Ruta (size increased to 20 X 20 for that) so you can see where they go.
    file Luffare.javapackage manswide;
    import java.awt.*;
    import javax.swing.*;
    public class Luffare extends JApplet
        Ruta rutor[] = new Ruta[400];
        public void init ()
            setLayout (null);
            for(int a = 0; a < 20; a++)
                for(int b = 0; b < 20; b++)
                    rutor[a * 20 + b] = new Ruta (a * 20 + b);
                    getContentPane ().add (rutor[a * 20 + b]);
                    rutor[a * 20 + b].setBounds (a * 20, b * 20, 20, 20);
    }file Ruta.javapackage manswide;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    class Ruta extends JPanel implements MouseListener, MouseMotionListener
        Rectangle rect;
        int id;
        public Ruta (int newId)
            id = newId;
            setBorder (LineBorder.createBlackLineBorder ());
            addMouseMotionListener (this);
            addMouseListener (this);
        public void paintComponent (Graphics g)
            Graphics2D g2 = (Graphics2D)g;
            g2.setFont (new Font("Arial", 1, 9));
            g2.drawString (Integer.toString (id), 2, 10);
        public void mouseReleased (MouseEvent e) {}
        public void mousePressed (MouseEvent e) {}
        public void mouseDragged (MouseEvent e) {}
        public void mouseMoved (MouseEvent e) {}
        public void mouseClicked (MouseEvent e) {}
        public void mouseExited (MouseEvent e) {}
        public void mouseEntered (MouseEvent e) {}
    }It's good practise to place each java class in its own file.
    db
    -- To post code, use the code button or type the code tags -- [code]CODE[/code] is displayed as CODE

  • Need help trying to create a ActiveX registered event

    I am trying to create a register event for an ActiveX component. The problem I am having is creating the callback vi. When I right click on the VI ref and create the callback vi it is created with the user parameter as a variant. I would like this to be a control refnum. If I open the callback vi and replace the user parameter variant with a control refnum the wire from the callback vi to the VI ref is broken. How do I change the user parameter?

    Joe is correct on this one. The callback where designed to take variants as their inputs, so that they are more flexible. In addition Variants are used through out ActiveX programming.
    If you have a control reference that you want to pass into the VI, all you need to use is the "To Variant" function in the main VI to turn the reference into a variant. You can then inside the Callback VI you can use the Variant to Data VI to change the variant back to a reference; you simply where a constant of the reference type to the "Type" terminal.
    Evan
    National Instruments

  • Trying to create a query that shows Sales Order/Invoice Totals as well as Paid/Outstanding/Available Down Payments

    Currently working on SAP B1 v8.82
    I'm looking to generate a query that will give an overall report for a given customer that shows Sales Order No, Invoice No, Sales Order Total, Invoice Total, Amount Paid on Invoice, Amount Remaining on Invoice, Down Payments Available, Open on Sales Order.
    I'm not sure what the best way to select the columns in bold above.  Invoice Total should be self-explanatory.  Amount Paid should be any down payments or applied payments on the invoice.  The balance due on the invoice (which seems to be T0.DocTotal if I'm not mistaken) should = 'Invoice Total' - 'Amount Paid on Invoice'. In the Down Payments Available column I want the total amount of money on the account or on down payments that aren't tied to a Sales Order.  If a client overpaid in the past for instance and there's a credit on their account, then it should contribute to this sum.  Open on Sales Order should be pretty easy.  I guess it's just the sum of everything that is still open on the Sales Order.  I'm just not sure what the best way to sum all the un-delivered freight, tax, and line items is.  Here's what my query looks like so far.
    SELECT DISTINCT T4.[DocNum] [Sales Order No],
    T0.DocNum [Invoice No],
    T4.DocTotal [Sales Order Total]
    T0.DocTotal [Amount Outstanding],
    FROM OINV T0
    INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN DLN1 T2 ON T1.BaseEntry = T2.DocEntry AND T1.BaseLine = T2.LineNum
    INNER JOIN RDR1 T3 ON T2.BaseEntry = T3.DocEntry AND T2.BaseLine = T3.LineNum
    INNER JOIN ORDR T4 ON T3.DocEntry = T4.DocEntry
    INNER JOIN OSLP T5 ON T4.SlpCode = T5.SlpCode
    WHERE T0.CardName Like '%%[%0]%%'
    GROUP BY T4.DocNum, T0.DocNum, T0.DocTotal, T4.DocTotal
    I tried doing a little searching around for queries similar to what I need, but I could find exactly what I was looking for and I'm very unfamiliar with OJDT, JDT1, and ITR1 tables which I think might be important to finding unapplied payments...

    Thanks.  There's a few problems though.
    1)  It seems that OINV DocTotal != Balance Due.  I'm seeing a number of invoices where there was a balance due, but we applied additional money (either we took another incoming payment and applied it or applied money from the account balance, etc.) and yet it still shows a total.
    2)  It's pulling incoming payments from different customers.  I think this is because the table was joined based on "RCT2 T4 on T4.[DocEntry]  =  T3.[DocNum] and T4.[InvoiceId] = T2.[LineNum]"  In one example I have 2 incoming payments 446 and 614.  Both have the DocEntry 542, but one relates to A/R Invoice 542 (for a different client) while the other relates to Down Payment Invoice 542.  *I was able to fix this by adding WHERE T5.CardCode = [%0]*
    3)  I'm going to work with this a little bit and see if I can alter it to make it work for me.  Basically this query falls a little short on the following:
    -  Doesn't include incoming payments that aren't linked to a down payment invoice.
    -  Does not give the Invoice Total (I'd like to know how much of the SO was invoiced.  DocTotal seems to give me Amount Invoiced - Down Payments.  I'm not sure the best way to get this number.  Maybe I could do the sum of each line * tax + freight)
    -  Does not give the outstanding amount on an invoice.  The ARtotal [DocTotal] column gives me how much was owed when the invoice was created, but it doesn't tell me what is currently owed.
    -  Lastly it may complicate the query too much and could be left off, but it would be nice to see if they have any money from credits or incoming payments that has not been applied.  Perhaps this would be easily accomplished by simply pulling in their account balance.

  • Help required in creating a QUERY!!!

    hi my name is johnny. I am new to this forums.
    My question is
    "There are 4 players in a team and that team played 4 matches. The scores for player1: 34,44,23,9. player2: 12,15,62,40. player3: 54,65,34,82. player4: 77,53,69,88. in four inning in four matches respectively. So my question is that i want highest score of each player in a column in the desceding order."
    Sample output:
    player_name test1 test2 test3 test4 highest_score
    player4 77 53 69 88 88
    player3 54 65 34 82 82
    player2 12 15 62 40 62
    player1 34 44 23 09 44

    Can you tell us how your data is stored in the database. I mean what is the table structure of the table that stores the data for all the inings and scores for all the players?
    Faisal.

  • Help trying to create a 2 page indesign doc with 1 landscape & 1 portrait page?

    I'm creating a double sided A5 flyer, how do I create a 2 page indesign document with one page portrait & the other landscape?
    Thank you in advance for anyone who can help with this ;-)

    You can use the Page tool to change one, but if it's going to print I think it would be better to make them both either ladscape or portrait, then use Rotate Spread View in the Pages panel to make one appear inthe other orientation on screen while work.

  • Help -- Trying to create JAR file but not working

    Hi everyone
    I have created a rather noddy Java program that consists of 4 JComboBox's and 1 JButton on a JFrame.
    When the button is clicked a text file is generate with the options that have been selected.
    There are severial files that the program uses for this:
    gcc.java
    OutToFile.java
    gccConfirm.java
    MyNewWindow.java
    main.java
    I am using Jcreator and so must use the command line to create the Jar file.
    I have never done a jar file before so I did an example with a hello world program and got it working now problem. I did the same for this program and the JAR file is generated without error. I double click on the JAR file to run the application, but nothing happens. I can see the application running in memory but nothing loads on the screen. However if I run it from the command line using Java -jar gcc.jar then everything is ok.
    can anyone help me here?
    thanks in advance

    If you run you .jar from the command line (a shell in unix speak) there
    already is a console where your java program can send it's System.out
    stuff. Right click on your .jar and select 'properties' (or similar). Note
    that your .jar is run by 'javaw'. This executable is similar to the 'java'
    executable except that it doesn't open a console for you. Change the
    'javaw' command to 'java' and voila, there's your console again.
    kind regards,
    Jos

  • Please help - Trying to create a realistic liquid morphing

    Hello
    I’m fairly new to Flash and vector art but have a
    project to create a Flash based flowchart that is made up of liquid
    blobs that morph to show the various paths to the chart.
    I’ve had a go making the blobs in flash but when l go
    to animate them, it all looks a bit rubbish - see:
    http://www.mintmedia.co.uk/example2.html
    Could anyone suggest a better way of attempting to do this
    animation....
    Thanks in advance
    Rich

    Is there no way to create an appcontroller that works like an applescript? Or get an applescript to be recognized so a new NSButton added to the Bookmark bar be activated?
    i.e.
    *tell application "System Events"*
    * tell application "Safari" to activate*
    * keystroke "n" using {command down}*
    * delay 0.1*
    * keystroke "l" using {command down, shift down}*
    *end tell*
    Or,
    _Something Like:_
    / AppController /
    *#import <Cocoa/Cocoa.h>*
    *@interface AppController : NSObject*
    *IBOutlet id NSButton;*
    *-(IBAction) autoFill:,delay 0.1,checkSpelling:(id)sender*
    @end
    I really don't know if that AppController looks anything like it should or if it's even close.

  • I need some help on creating a query

    This is my first crack at writing query's.  
    I am trying to create a query for a list on clients with a file name on the system. I found a lot of samples on the web, however i keep getting errors on all of them. 
    Here is on sample:
    select SMS_G_System_COMPUTER_SYSTEM.Name, 
    SMS_G_System_SoftwareFile.FilePath, SMS_G_System_SoftwareFile.CreationDate, 
    SMS_G_System_SoftwareFile.FileDescription, V_R_System.ResourceType, 
    V_R_System.ResourceId from V_R_System inner join SMS_G_System_COMPUTER_SYSTEM on 
    SMS_G_System_COMPUTER_SYSTEM.ResourceID = V_R_System.ResourceId inner join SMS_G_System_SoftwareFile on 
    SMS_G_System_SoftwareFile.ResourceID = V_R_System.ResourceId where SMS_G_System_SoftwareFile.FileName = "test1234.exe" 
    First i was getting an error:
    Invalid object name 'SMS_R_System' and i had to change to V_R_System instead of SMS_R_System. "Is it because
    SQL and WQL difference?????"
    Now i am getting Invalid object name 'SMS_G_System_COMPUTER_SYSTEM' "Here is where i am stuck"
    If possible i would like to explanation as well "maybe some good links", please keep in mind just getting started with query's.
    Thanks for the help.
    I am writing/testing query in sql management studio.
    If there is a better way or a tool please let me know.

    The application i am looking for does not show up in ADD/REM.
    I was asking what is the difference between V_R_System instead of SMS_R_System?
    And what should i use instead of SMS_G_System_COMPUTER_SYSTEM?
    Maybe you can share some links so i can read a little more?
    Thank you.

  • Need to create report query to get latest open and last closed period for given application

    Hi All,
    I need to create a report query to get below result displayed in report output.
    1)   -   Application name
    2)   -    Ledger name
    -o/  -Operating Unit
    3)   -  Last Closed Period
    4)   -  Current Open Period
    5)   -  Date Closed – Last Closed Period
    6)   -  Date Open – Current Open Period
    I tr I tried to create the query below is the same. Please let me know if it looks fine.
    SELECT *
      FROM (SELECT fav.application_name ,
                   hou.name Operating_Unit_Name,
                   gl.name Ledger_name,
                   gl.latest_opened_period_name,
                   gps.period_name Period_Name,
                   DECODE(gps.closing_status, 'O', 'Open', 'C', 'Closed') status,
                   gps.last_update_date Last_status_modified_date
              FROM gl_period_statuses gps,
                   gl_sets_of_books   gsob,
                   fnd_application_vl fav,
                   hr_operating_units hou,
                   gl_ledgers         gl
             WHERE gps.period_name = gps.period_name
               AND gps.closing_status ='C'
               AND fav.application_short_name =
                   NVL('&p_application_short_name', fav.application_short_name)
               AND gps.application_id = fav.application_id
               AND gsob.set_of_books_id = gps.set_of_books_id
               AND hou.set_of_books_id = gps.set_of_books_id
               AND gl.ledger_id = gsob.set_of_books_id
               AND hou.organization_id=NVL('&p_operating_unit',hou.organization_id)
               AND gl.ledger_id=NVL('&p_ledger_id',gl.ledger_id) 
             ORDER BY gps.last_update_date desc )WHERE ROWNUM = 1 
    UNION ALL
    SELECT *
      FROM (SELECT fav.application_name Application_Name,
                   hou.name Operating_Unit_Name,
                   gl.name Ledger_name,
                   gl.latest_opened_period_name,
                   gps.period_name Period_Name,
                   DECODE(gps.closing_status, 'O', 'Open', 'C', 'Closed') status,
                   gps.last_update_date Last_status_modified_date
              FROM gl_period_statuses gps,
                   gl_sets_of_books   gsob,
                   fnd_application_vl fav,
                   hr_operating_units hou,
                   gl_ledgers         gl
             WHERE gps.period_name = gps.period_name
               AND gps.closing_status = 'O'
               AND fav.application_short_name =
                   NVL('&p_application_short_name', fav.application_short_name)
               AND gps.application_id = fav.application_id
               AND gsob.set_of_books_id = gps.set_of_books_id
               AND hou.set_of_books_id = gps.set_of_books_id
               AND gl.ledger_id = gsob.set_of_books_id
               AND hou.organization_id=NVL('&p_operating_unit',hou.organization_id)
               AND gl.ledger_id=NVL('&p_ledger_id',gl.ledger_id) 
             ORDER BY gps.last_update_date desc)
             WHERE ROWNUM = 1

    It is within the table I believe (I'm not a DBA or a developer) since I created a BLOB column and then used the file browse feature to allow users to attach a resume to the table in order to be able to perform a search of the attached documents.
    I'm just having a hard time pointing the link in the search results report to the document in the blob column.
    The information on that page is great if you're trying to create a link to the document on the initial report.
    But I created a query using Oracle Text to run a report that does a boolean search of the attached word documents in the table.
    When it displays the search results, it doesn't create a link to the document and I can't figure out how to do it.
    Here's a link the the instructions I used to create the initial search report with Oracle Text, mind you I only created the index and query, I didn't add in all the link data since they're using documents on websites and I'm using documents in a table.
    http://www.oracle.com/technology/products/database/application_express/pdf/apex_text_application_v1.6.pdf
    If you can help me with this I'd really appreciate it.
    Thanks again.
    Greg
    Edited by: gjones77 on Dec 2, 2008 8:14 AM

Maybe you are looking for