How to display result of a query in browser?

I have to write a simple application where I use EJB to access a database and then use Servlet/JSP to display the data to a browser. can anyone help me out please?

in my ejb i am taking the input as claim number and using a select query i am getting the row for the particular claim number from the database. Through a servlet i need to invoke the ejb and get the data(result of the query) displayed in a browser. I want to know a way to display the query result in the browser.

Similar Messages

  • How to display result of database query in JFrame?

    How to display result of oracle database query in JFrame?
    This is part of my code:
    String username, password;
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
              OracleConnection conn = DriverManager.getConnection(String url, String username, String password);
    Statement s= conn.createStatement();
    ResultSet q= s.executeQuery("SELECT A, B, C FROM TABLE X");
    Forget what url, username & password are. Is there any problem with my code?
    What should be next if I want to display result of the query in a table in JFrame?Thx !

    How to create JTable with unknown no. of rows? How to get no. of rows of a query?
    I saw the demo of creating JTable on java.sun.com but the the table has a certain no. of rows which is not applicable to my case.
    Suppose the result of query is a table with 3 attributes so there are 3 columns in the table.
    R contains the result of the query.
    Should it be something like this if I want to create JTable of the query?
    How to make n rows of {R.getString(1),R.getString(2),R.getString(3)};?
    public SimpleTableDemo() {
    super(new GridLayout(1,0));
    String[] columnNames = {"A",
    "B",
    "C",
    while (R.next())
    // content of a row
    Object[][] data = {R.getString(1),R.getString(2),R.getString(3)};
    I can't run it because I still can't debug my code which is said before.
    Thx!

  • Unable to display results of multiple query in grid in Oracle SQL Developer

    Hi, I am a newbie to this forum and couldn't find the Oracle SQL Developer forum so posting it here.
    My question: How to display multiple query results in grid in Oracle SQL Developer.
    Example:
    select * from Employee;
    select * from Department;
    - when I select both the queries and hit F5 in Oracle sql developer. By default it displays in output window.
    - How to display result of both the queries in Grid.
    Any thoughts on this would be really helpful.
    Thanks in advance.
    Harsh

    Hi Harsh,
    I'd say that the Results grid is designed to only show the results of 1 query at a time. I don't know/can't see how it would display multiple queries at a time.
    I would suggest either joining your tables to create a single query or opening another SQL Worksheet for one of the queries so that you can display the results side-by-side.
    Maybe you could explain what you're trying to do. Why are you trying to display multiple results in the same query grid?

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • How to display current date in query header?

    Hi,
    How to display current date in query header?
    I use Query Designer for development.
    Thanks,
    Arun KK

    Hi Arun,
    You can define fixed header lines and footer lines so that when you generate the query list, they can receive current values of certain fields. When you define a header line or a footer line, you must specify a character string of the type &field, where field is the short name of a field.
    This function allows you (for example) to place a sort criterion in the header line.
    You can include the following fields as variables in the headers directly:
    %NAME
    Name of the user processing the query
    %DATE
    Current date
    %TIME
    Current time
    %PAGE
    Current page number (6 characters)
    %P
    Current page number (3 characters)
    These fields can be used in the short forms N,D,T and P. If you want to use these letters as short names for query fields, the field values from the query are used.
    You can also see the link
    [http://help.sap.com/saphelp_nw70/helpdata/EN/6e/dd68721faf11d6b1d500508b6b8b11/frameset.htm]
    Regards,
    NR

  • Display results of MySQL query from AMFPHP by ArrayCollection in AS3 (Flash CS4)

    Hi, i am using Flash CS4 (AS3) + AMFPHP + MySQL to do own flash frontend for Wordpress CMS.  Everything is going fine but i`ve got one problem. Problem with properly display of result of query in AS3 by using ArrayCollection.
    When i check my service in "amfphp/browser/" in web browser i`ve got this (with all needed data):
    (mx.collections::ArrayCollection)#0
    filterFunction = (null)
    length = 2
    list = (mx.collections::ArrayList)#1  
    length = 2     source = (Array)#2
    That is the reason that i suppose that service work fine.  Problem is when i try to display result in AS3. In actionscript i have got this:
    function getNewsListHandler(result:Object):void{
    trace(result);
    This function displays: [object Object].
    I know that "result" is an ArrayCollection type but i don`t know how to get rows and columns from this. I know that my data is there but i have no idea how to get it.
    Clarify: I don`t know how to get to Arrays and simple data variables which are in ArrayCollection.
    Could anyone help me with that problem. I would be gratefull
    P.S. I tried also change query type in service.PHP for mysql_fetch_query but in that case i`ve got only one row (not all data).

    Thanks for fast reply,
    arr_coll:ArrayCollection = new ArrayCollection ({col1:"data1",col2:"data2"}, {col1:"data3",col2:"data4"});
    you would get the data like
    var resultstr:String = arr_coll[1][1].col2;
    trace(resultstr);
    //results in data4
    could you explain me how it was happen (arr_coll[1][1].col2)? It`s not clear to me. I thought in this case rather something like this :
    var resultstr:String = arr_coll[1]['col2'];
    It should give me "data4". I know it wasn`t but i don`t understand ArrayCollection in level which is needed to use your advice in my case. Could you clarify "arr_coll[1][1].col2" a bit?
    What would it look like when you would have something like this:
    arr_coll:ArrayCollection = new ArrayCollection ({col1:"data1",col2:"data2"}, {col1:"data3",col2:"data4"},{col1:"data5",col2:"data6"},{col1:"data7",col2:"data8"});
    and you would want know f.e. position in ArrayCollection of  "data6". How would you code this? arr_coll[1][2].col2?

  • Displaying results of a query

    Hi there
    I want to display the results of a query.
    OK I do kow how to do that. I do have one long text field
    (MySQL) and in some cases the colomn I iwsh to display has a page
    of information. I just want to display say the first 300
    characters. I was initionally thinking rtrim or trim but tralise
    that doesnt do it.
    I cant find what the correct term is.
    Thanks in advance

    Actually, I believe the Right() function returns the last
    part of the text, you will want to use the Left() function to
    return the first part. . . .
    http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/js/html/wwhelp.htm?hre f=00000617.htm
    -Mike

  • How to use Results from Another Query for SAP BW universes

    Hi Everyone,
    I have two SAP BI universes.In my First universe I have Sales Doc no (dimension) and Orderqty (Measure) and in my second universe I have Sales Doc no(Dimension) and BillQty (Measure).
    Here in my first dataprovider I have 1200 rows of data and in second dataprovider I have 75,000 rows. The report should fetch only the BillQty details that matches to corresponding  Sales doc no in first data provider.
    I want to place all these fileds into a single report like as shown.
    (Datarpovider1)                (Datarpovider1)                    (Datarpovider2)
    *Sales Doc No*               Orderqty                           BillQty
    Here I am able to generate single report using merge dimension but it is leading to performance issues. I want to restrict the values at query level by passing the First dataprovider Sales doc no to second Data provider Sales doc number using Results from Anothery Query feature so that It can fetch only the matching records.
    I tried it but it was giving the follwing error:
    A filter contains a wrong value. You cannot run this query. (Error: WIS 00007)
    How Can I get rid of this error. Can we use Results from Anothery Query option for OLAP universe. Are there any limitation on it.
    All this I am doing in Webi Rich Client.
    Appreciate your help
    Thanks &in Advance
    Kiran Saka

    Hi Kiran,
    I think the filter has a wrong operand. For example, a filter with an empty constant, or a filter that deals with numeric values is defined with an alphanumeric value.Check out for this.
    Regards,
    Neeraj

  • How to get result of select query from  oracle  in VC

    Dear All ,
    I have a application in oracle which insert the data in the oracle database table.
    Now i want to show all the data that has been inserted into the database table in my VC application but i don't know how to handle select query in VC.
    Regards
    Krishan

    Hi Goivndu
    Thanks for your reply .
    I know all those things.
    I have created the system & alias  for my backend oracle system.
    I can also see all the stored procedure that are there in my oracle system.
    I just want to know how to write a select query in a stored procedure .
    you can insert data , Update data through oracle procedure but i don't think there is any way to get the result of select query in stored procedure .
    If you know any way to do that please do let me know .
    Regards
    Krishan

  • How to present result of DB-Query blasting all formats in width

    Hi,
    i'm searching for an idea/solution for the problem:
    Users of my form shall be able to choose an item of a result list of a DB-Query. Unfortunatelly there are too many attributes with alternating length per line, that have to be showed there. Using multiple line per tuple would blast the form in length instead of width, which is not acceptable, too. Something for scrolling within a little window would be most appropriate.
    Nevertheless there is not a table object at all in Designer, as i read in this forum. (This is to my mind a real lack of function. Maybe a new version might offer this?)
    Currently i'm developing the form as a test for pdf. Later on the forms shall be developed for HTML as soon as the Form Server 7 is available and implemented.
    Maybe somebody has thought about the same problem or has an idea how this could be solved.
    Thanks in advance for any response
    Kermit
    Kermit

    Hi Goivndu
    Thanks for your reply .
    I know all those things.
    I have created the system & alias  for my backend oracle system.
    I can also see all the stored procedure that are there in my oracle system.
    I just want to know how to write a select query in a stored procedure .
    you can insert data , Update data through oracle procedure but i don't think there is any way to get the result of select query in stored procedure .
    If you know any way to do that please do let me know .
    Regards
    Krishan

  • How to display results set of multiple reports into a single report table

    Our goal is to create a single report (or dashboard) that shows the "funnel" of object creations related to each campaign. The flow goes from Activity to Lead to Opportunity as well as multiple steps within each (ie. Unqualified Lead -> Qualified Lead, etc).
    We currently have 3 separate reports in three different subject areas, each reporting the different metrics and we would like to combine the output into a single Unified report.
    For example what we currently have is:
    Activities:
    Campaign Name # of Activities
    Campaign A 12
    Campaign B 26
    Leads:
    Campaign Name # of Leads # of Qualified Leads
    Campaign A 10 4
    Campaign B 20 18
    Opportunities:
    Campaign Name # of Opportunities # of Opps per Sales Stage ... # of Wins Closed Revenue
    Campaign A 3 2 1 $1,000.00
    Campaign B 10 8 3 $2,800.00
    What we want to see is:
    Combined:
    Campaign Name - Campaign Cost - # of Activities - # of Leads - # of Qualified Leads - # of Opportunities - # of Opps per Sales Stage - # of Wins - Closed Revenue
    Campaign A - $423.00 - 12 - 10 - 4 - 3 - 2 - 1 - $1,000.00
    Campaign B - $ 1,000.00 - 26 - 20 - 18 - 10 - 8 - 3 - $2,800.00
    We have tried using the "Combine with similar analysis" but the number of columns for each subject area differ. We also tried creating multiple UNION criteria (one for each column), but in the case of # of Opps per Sales Stage and Closed Revenue, those are not "Metrics" fields, so they won't combine.

    Hi, You may have to create some dummy fields to equate the no. of field in each of the report matching the data type too and get a one single report using combined analytics and then using the resultant data you can create a simple pivot like below. Haven't tried it before
    -- Venky CRMIT
    Hi Venky,
    I am facing the same problem. Can you please say Steps how to create resultant data and Combine in pivot Table .
    Please Help me .
    Thanks in Advance .
    My mail id is :
    [email protected]

  • How to display results of a report based on current year

    Hi,
    Please advice me for the following requirement.
    I have a report which is having sales results, which is having year column also. Report has to be displayed based on the current year. Now it is 2013. I should show current year results only i.e 2013.
    In 2014, i should show only 2014 results. How to achieve this at a report level.
    regards
    CK.

    Hi CK,
    You are having Data for 2014 also. If not means, you can use sql query select max(year) from period.
    So it will show the final maximum end of the year(2013) from database.
    You can use dashboard prompts too. in the prompt also you can have specific year or sql query
    http://mkashu.blogspot.com
    Regards,
    VG

  • How to display result set boolean value as a check box

    Hi guys,
    I am getting the data which include boolean from the database, i need to display the boolean values as check box, see my code, its displaying the data into the table with the boolean values as true and false, how to make it in check boxes
    package swing2.org;
    import java.awt.GridBagLayout;
    import javax.swing.JPanel;
    import java.awt.Color;
    import javax.swing.BorderFactory;
    import javax.swing.border.BevelBorder;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import java.awt.Container;
    import java.awt.GridBagConstraints;
    import java.awt.ComponentOrientation;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    public class Panel2 extends JPanel {
         private static final long serialVersionUID = 1L;
         private JScrollPane jScrollPane = null;
         private JTable jTable = null;
          * This is the default constructor
         public Panel2() {
              super();
              initialize();
          * This method initializes this
          * @return void
         private void initialize() {
         //     Panel2.ResultSetFrame();
              GridBagConstraints gridBagConstraints = new GridBagConstraints();
              gridBagConstraints.fill = GridBagConstraints.BOTH;
              gridBagConstraints.gridy = 0;
              gridBagConstraints.weightx = 1.0;
              gridBagConstraints.weighty = 1.0;
              gridBagConstraints.gridx = 0;
              this.setSize(340, 200);
              this.setLayout(new GridBagLayout());
              this.setBackground(new Color(171, 211, 224));
              this.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED), null));
              this.add(getJScrollPane(), gridBagConstraints);
          * This method initializes jScrollPane     
          * @return javax.swing.JScrollPane     
         private JScrollPane getJScrollPane() {
              if (jScrollPane == null) {
                   jScrollPane = new JScrollPane();
                   jScrollPane.setViewportView(getJTable());
              return jScrollPane;
          String[] columnNames = {"Task Description",
                 "Time ",
                 "Pop-up",
                 "Sound",
                 "Delete"};
          * This method initializes jTable     
          * @return javax.swing.JTable     
         private JTable getJTable() {
                      ResultSetFrame oo = new ResultSetFrame();
                      JTable table = new JTable(oo.model);
                      table.setBackground(new Color(195, 217, 230));
                      table.setComponentOrientation(ComponentOrientation.UNKNOWN);
                      table.setShowGrid(true);
                      table.setShowVerticalLines(true);
                      table.setRowHeight(17);
                      table.setShowHorizontalLines(true);
                      return table;
    abstract class ResultSetTableModel extends AbstractTableModel
         public ResultSetTableModel(ResultSet aResultSet)
              rs = aResultSet;
          try
               rsmd = rs.getMetaData();     
          catch(SQLException e)
               System.out.println("Error " + e);
       public String getColumnName(int c)
       {  try
          {  return rsmd.getColumnName(c + 1);
          catch(SQLException e)
          {  System.out.println("Error " + e);
             return "";
       public int getColumnCount()
       {  try
          {  return rsmd.getColumnCount();
          catch(SQLException e)
          {  System.out.println("Error " + e);
             return 0;
       protected ResultSet getResultSet()
       {  return rs;
       private ResultSet rs;
       private ResultSetMetaData rsmd;
    class CachingResultSetTableModel extends ResultSetTableModel
    {  public CachingResultSetTableModel(ResultSet aResultSet)
       {  super(aResultSet);
          try
          {  cache = new ArrayList();
             int cols = getColumnCount();
             ResultSet rs = getResultSet();
             /* place all data in an array list of Object[] arrays
                We don't use an Object[][] because we don't know
                how many rows are in the result set
             while (rs.next())
             {  Object[] row = new Object[cols];
                for (int j = 0; j < row.length; j++)
                   row[j] = rs.getObject(j + 1);
                cache.add(row);
          catch(SQLException e)
          {  System.out.println("Error " + e);
       public Object getValueAt(int r, int c)
       {  if (r < cache.size())
             return ((Object[])cache.get(r))[c];
          else
             return null;
       public int getRowCount()
       {  return cache.size();
       private ArrayList cache;
    class ResultSetFrame 
    {  public ResultSetFrame()
          /* find all tables in the database and add them to
             a combo box
          try
          {  Class.forName("com.mysql.jdbc.Driver");
             con = DriverManager.getConnection("jdbc:mysql://localhost:3306/task","root","nbuser");
                stmt = con.prepareStatement("SELECT * FROM tasky");
                   try
                    String query = "SELECT * FROM tasky";
                    rs = stmt.executeQuery(query);
                    model = new CachingResultSetTableModel(rs);
                    JTable table = new JTable(model);
                    scrollPane = new JScrollPane(table);
                catch(SQLException e)
                     System.out.println("Error " + e);
          catch(ClassNotFoundException e)
          {  System.out.println("Error " + e);
          catch(SQLException e)
          {  System.out.println("Error " + e);
       private JScrollPane scrollPane;
       public ResultSetTableModel model;
       private ResultSet rs;
       private Connection con;
       private Statement stmt;
    }

    add a
    public Class getColumnClass(int col) {
         return getValueAt(0, col).getClass();
    }in your ResultSetTableModel which extends AbstractTableModel.
    A simple example
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.SwingUtilities;
    import javax.swing.table.AbstractTableModel;
    public class SimpleDemo extends JFrame {
        public SimpleDemo() {
            createAndShowUI();
        private void createAndShowUI(){
            String[] columnName = {"CheckBox Column", "Data Column"};
            Object[][] data = {{new Boolean(true), "Data 1"},
            {new Boolean(false), "Data 2"}, {new Boolean(true), "Data 3"}};
            MyModel model = new MyModel();
            model.setData(columnName, data);
            JTable myTable = new JTable(model);
            JScrollPane scrollPane = new JScrollPane(myTable);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            getContentPane().add(scrollPane);
            pack();
            setLocationRelativeTo(null);
        class MyModel extends AbstractTableModel {
            String[] columnName;
            Object[][] data;
            public void setData(String[] colName, Object[][] theData) {
                this.columnName = colName;
                this.data = theData;
                fireTableStructureChanged();
            public String getColumnName(int column) {
                return columnName[column];
            public Object getValueAt(int rowIndex, int columnIndex) {
                return data[rowIndex][columnIndex];
            public int getRowCount() {
                return data.length;
            public int getColumnCount() {
                return columnName.length;
            public Class getColumnClass(int c) {
                return getValueAt(0, c).getClass();
        public static void main(String[] args){
            Runnable run = new Runnable(){
                public void run(){
                    new SimpleDemo().setVisible(true);
            SwingUtilities.invokeLater(run);
    }

  • Display results from dynamic query created and executed inside procedure

    Hi;
    I have created this code:
    CREATE OR REPLACE PROCEDURE RunDynamicQuery(Var1 IN VARCHAR2, Var2 IN VARCHAR2, VAR3 IN VARCHAR2) AS
    -- Do something
    -- That ends up with a variable holding a query.... (just an example)
    MainQuery :='select sysdate from dual';
    end RunDynamicQuery;
    How can I run this procedure and see the result on the dymanic query generated inside it?
    BEGIN
    compare_tables_content('VAR1','VAR2','VAR3');
    END;
    Expected Output for this given example:
    20-05-2009 11:04:44 ( the result of the dymanic query inside the procedure variable MainQuery :='select sysdate from dual';)
    I tested with 'execute immediate':
    CREATE OR REPLACE PROCEDURE RunDynamicQuery(Var1 IN VARCHAR2, Var2 IN VARCHAR2, filter IN VARCHAR2) AS
    -- Do something
    -- That ends up with a variable holding a query.... (just an example)
    MainQuery :='select sysdate from dual';
    execute immediate (MainQuery );
    end RunDynamicQuery;
    BEGIN
    compare_tables_content('VAR1','VAR2','VAR3');
    END;
    Output:"Statement processed'' (no sysdate displayed ! )
    Please consider that the collums in the query are always dynamic... PIPELINE Table would not work because I would need to define a container, example:
    CREATE OR REPLACE TYPE emp_tabtype AS TABLE OF emp_type;
    FUNCTION RunDynamicQuery (p_cursor IN sys_refcursor)
    RETURN emp_tabtype PIPELINED
    IS
    emp_in emp%ROWTYPE;
    BEGIN
    LOOP
    FETCH p_cursor
    INTO emp_in;
    EXIT WHEN p_cursor%NOTFOUND;
    PIPE ROW (...)

    That would be a nice solution, thanks :)
    ''For now'' I implemented like this:
    My dynamic query now returns a single string ( select col1 || col2 || col3 from bla)
    This way I don't have dynamic collumns issue, and from business side, this ''string'' format works for them.
    This way I can use the pipelines to get the result out...
    OPEN myCursor FOR MainQuery;
    FETCH myCursor
    INTO myRow;
    WHILE (NOT myCursor%notFound) LOOP
    PIPE ROW(myRow);
    FETCH myCursor
    INTO myRow;
    END LOOP;
    CLOSE myCursor;

  • How to display result order by date desc?

    Hi Everyone,
    My DB version is
    BANNER                                                        
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production                          
    CORE 10.2.0.1.0 Production                                        
    TNS for Linux: Version 10.2.0.1.0 - Production                  
    NLSRTL Version 10.2.0.1.0 - Production                          
    Please do have a look at this query and the result displayed. It's always showing results in draw_dt asc. I need to get this result as draw_dt desc. Please suggest something.
    select rownum as sl_no,
           sub.patient_name,
           sub.external_id,
           sub.modality,
           sub.account_number,
           sub.hlab_num,
           sub.spectra_mrn,
           sub.draw_dt,
           sub.requisition_number,
           sub.facility_name,
           sub.facility_id,
           sub.corporation_name,
           sub.acronym,
           sub.patient_id,
           SUB.TEST_ID,
           count(sub.requisition_number) over (partition by null) as entity_count
    from(
    select distinct
            (select p.last_name || ', ' || p.first_name
              from patient p
             where p.patient_id = loc.patient_id) as patient_name,
           (select p.external_id
              from patient p
             where p.patient_id = loc.patient_id) as external_id,
           (select p.spectra_mrn
            from patient p
            where p.patient_id = loc.patient_id) as spectra_mrn,
           ord.requisition_number as requisition_number,
           f.facility_name as facility_name,
           f.facility_id as facility_id,
           (select fad.account_type as modality
              from patient p,
                   patient_facility_modality pfm,
                   facility_account_modality fam,
                   facility_account_detail fad
             where p.patient_id = pfm.patient_id
               and pfm.facility_account_modality_id =
                                                  fam.facility_account_modality_id
               and fam.facility_account_detail_id = fad.facility_account_detail_id
               and p.patient_id = loc.patient_id
               and pfm.facility_id = loc.facility_id) as modality,
           (select fad.account_number as account_number
              from patient p,
                   patient_facility_modality pfm,
                   facility_account_modality fam,
                   facility_account_detail fad
             where p.patient_id = pfm.patient_id
               and pfm.facility_account_modality_id =
                                                  fam.facility_account_modality_id
               and fam.facility_account_detail_id = fad.facility_account_detail_id
               and p.patient_id = loc.patient_id
               and pfm.facility_id = loc.facility_id) as account_number,
           (select fad.hlab_num as hlab_num
              from patient p,
                   patient_facility_modality pfm,
                   facility_account_modality fam,
                   facility_account_detail fad
             where p.patient_id = pfm.patient_id
               and pfm.facility_account_modality_id =
                                                  fam.facility_account_modality_id
               and fam.facility_account_detail_id = fad.facility_account_detail_id
               and p.patient_id = loc.patient_id
               and pfm.facility_id = loc.facility_id) as hlab_num,
           loc.order_draw_dt as draw_dt,
           c.corporation_name as corporation_name,
           c.corporation_acronym as acronym,
           loc.patient_id,
           loct.test_id
      from lab_order_occ loc,
           lab_order_occ_test loct,
           facility f,
           corporation c,
           order_requisition_header ord
    where loc.lab_order_occ_id = loct.lab_order_occ_id
       and loc.facility_id = f.facility_id
       and f.corporation_id = c.corporation_id
       and ord.patient_id = loc.patient_id
       and ord.facility_id = loc.facility_id
       and ord.draw_dt = loc.order_draw_dt
       and loc.order_draw_dt between sysdate - 65 and sysdate
       and loc.status = 'A'
       and loc.msg_sent_to_lab_yn = 'Y'
       and loct.test_id in (
                       select test_id
                         from test_required
                        where required_test_code in (
                                                     select test_code
                                                       from interface_adt_aoe_master))
       and upper (c.corporation_acronym) in ('CORVA', 'DSI', 'USRC', 'DLYSNEWCO')
       and not exists (
                        select 1 from emr_adtaoe_dtl
                        where patient_id = loc.patient_id
                        and facility_id = loc.facility_id
                        and status = 'Y'
                        ))sub
    ORDER BY
            sub.draw_dt,
    --         sl_no,
             sub.corporation_name,
             sub.facility_name,
             SUB.PATIENT_NAME
             desc;
    Result
    SL_NO
    PATIENT_NAME
    EXTERNAL_ID
    MODALITY
    ACCOUNT_NUMBER
    HLAB_NUM
    SPECTRA_MRN
    DRAW_DT
    REQUISITION_NUMBER
    FACILITY_NAME
    FACILITY_ID
    CORPORATION_NAME
    ACRONYM
    PATIENT_ID
    TEST_ID
    ENTITY_COUNT
    9
    New, Pat
    123456
    HEMO
    72910
    A102805
    366999
    29-DEC-13
    9KT005A
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    2
    New, Pat
    123457
    HEMO
    72910
    A102805
    366999
    29-DEC-13
    9KT0057
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    7
    New, Pat
    123458
    HEMO
    72910
    A102805
    366999
    29-DEC-13
    9KT0059
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    16
    Erere, Gggg
    123459
    HEMO
    72910
    A102805
    622200
    29-DEC-13
    9KT0058
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    622
    5558
    16
    10
    Erere, Gggg
    123460
    HEMO
    72910
    A102805
    622200
    29-DEC-13
    9KT0056
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    622
    5558
    16
    1
    Test, Pat
    123461
    HEMO
    72910
    A102805
    367021
    30-DEC-13
    9KT0065
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    14
    Test, Pat
    123462
    HEMO
    72910
    A102805
    367021
    30-DEC-13
    9KT0064
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    4
    New, Pat
    123463
    HEMO
    72910
    A102805
    366999
    30-DEC-13
    9KT005W
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    3
    New, Pat
    123464
    HEMO
    72910
    A102805
    366999
    30-DEC-13
    9KT005X
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    8
    New, Pat
    123465
    HEMO
    72910
    A102805
    366999
    30-DEC-13
    9KT005V
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    13
    Test, Pat
    123466
    HEMO
    72910
    A102805
    367021
    01-JAN-14
    9KT006J
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    5
    Test, Pat
    123467
    HEMO
    72910
    A102805
    367021
    01-JAN-14
    9KT006G
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    6
    Test, Pat
    123468
    HEMO
    72910
    A102805
    367021
    01-JAN-14
    9KT006H
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    11
    Test, Pat
    123469
    HEMO
    72910
    A102805
    367021
    05-JAN-14
    9KT0077
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    15
    Test, Pat
    123470
    HEMO
    72910
    A102805
    367021
    05-JAN-14
    9KT0076
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    12
    New, Pat
    123471
    HEMO
    72910
    A102805
    366999
    06-JAN-14
    9KT0075
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    See the date value for draw_dt column. It's always in asc order. How can I display this result set with draw_dt desc order? Please suggest something.

    ORDER BY  
            sub.draw_dt desc, 
    --         sl_no, 
             sub.corporation_name, 
             sub.facility_name, 
             SUB.PATIENT_NAME 
             desc;

Maybe you are looking for