Help query with having or count class

Hi gurus,
I want to pull the records  from this table ,whihc are having only the two xtn's , do i need to have having with the count ? kindly suggest
select distinct ID, MCC, XTN
from prod.merch_xtn_serv
where xtn in  (1,18)
GROUP BY ID,MCC,XTN
ORDER BY ID ,mcc,XTN

Hi,
978485 wrote:
Hi gurus,
I want to pull the records  from this table ,whihc are having only the two xtn's , do i need to have having with the count ? kindly suggest
select distinct ID, MCC, XTN
from prod.merch_xtn_serv
where xtn in  (1,18)
GROUP BY ID,MCC,XTN
ORDER BY ID ,mcc,XTN
It depends on your data and your requirements.
Whenever you have a question, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
Without that information, it's unclear what you want.  It sounds like a HAVING clause would be a good solution; maybe you want 2 separate conditions in the HAVING clause, each using COUNT.

Similar Messages

  • Help needed with passing data between classes, graph building application?

    Good afternoon please could you help me with a problem with my application, my head is starting to hurt?
    I have run into some difficulties when trying to build an application that generates a linegraph?
    Firstly i have a gui that the client will enter the data into a text area call jta; this data is tokenised and placed into a format the application can use, and past to a seperate class that draws the graph?
    I think the problem lies with the way i am trying to put the data into co-ordinate form (x,y) as no line is being generated.
    The following code is from the GUI:
    +public void actionPerformed(ActionEvent e) {+
    +// Takes data and provides program with CoOrdinates+
    int[][]data = createData();
    +// Set the data data to graph for display+
    grph.showGrph(data);
    +// Show the frame+
    grphFrame.setVisible(true);
    +}+
    +/** set the data given to the application */+
    +private int[][] createData() {+
    +     //return data;+
    +     String rawData = jta.getText();+
    +     StringTokenizer tokens = new StringTokenizer(rawData);+
    +     List list = new LinkedList();+
    +     while (tokens.hasMoreElements()){+
    +          String number = "";+
    +          String token = tokens.nextToken();+
    +          for (int i=0; i<token.length(); i++){+
    +               if (Character.isDigit(token.charAt(i))){+
    +                    number += token.substring(i, i+1);+
    +               }+
    +          }     +
    +     }+
    +     int [][]data = new int[list.size()/2][2];+
    +     int index = -2;+
    +     for (int i=0; i<data.length;i++){+
    +               index += 2;+
    +               data[0] = Integer.parseInt(+
    +                         (list.get(index).toString()));+
    +               data[i][1] = Integer.parseInt(+
    +                         (list.get(index +1).toString()));+
    +          }+
    +     return data;+
    The follwing is the coding for drawing the graph?
    +public void showGrph(int[][] data)  {+
    this.data = data;
    repaint();
    +}     +
    +/** Paint the graph */+
    +protected void paintComponent(Graphics g) {+
    +//if (data == null)+
    +     //return; // No display if data is null+
    super.paintComponent(g);
    +// x is the start position for the first point+
    int x = 30;
    int y = 30;
    for (int i = 0; i < data.length; i+) {+
    +g.drawLine(data[i][0],data[i][1],data[i+1][0],data[i+1][1]);+
    +}+
    +}+

    Thanks for that tip!
    package LineGraph;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.util.List;
    public class GUI extends JFrame
      implements ActionListener {
      private JTextArea Filejta;
      private JTextArea jta;
      private JButton jbtShowGrph = new JButton("Show Chromatogram");
      public JButton jbtExit = new JButton("Exit");
      public JButton jbtGetFile = new JButton("Search File");
      private Grph grph = new Grph();
      private JFrame grphFrame = new JFrame();   // Create a new frame to hold the Graph panel
      public GUI() {
         JScrollPane pane = new JScrollPane(Filejta = new JTextArea("Default file location: - "));
         pane.setPreferredSize(new Dimension(350, 20));
         Filejta.setWrapStyleWord(true);
         Filejta.setLineWrap(true);     
        // Store text area in a scroll pane 
        JScrollPane scrollPane = new JScrollPane(jta = new JTextArea("\n\n Type in file location and name and press 'Search File' button: - "
                  + "\n\n\n Data contained in the file will be diplayed in this Scrollpane "));
        scrollPane.setPreferredSize(new Dimension(425, 300));
        jta.setWrapStyleWord(true);
        jta.setLineWrap(true);
        // Place scroll pane and button in the frame
        JPanel jpButtons = new JPanel();
        jpButtons.setLayout(new FlowLayout());
        jpButtons.add(jbtShowGrph);
        jpButtons.add(jbtExit);
        JPanel searchFile = new JPanel();
        searchFile.setLayout(new FlowLayout());
        searchFile.add(pane);
        searchFile.add(jbtGetFile);
        add (searchFile, BorderLayout.NORTH);
        add(scrollPane, BorderLayout.CENTER);
        add(jpButtons, BorderLayout.SOUTH);
        // Exit Program
        jbtExit.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e) {
             System.exit(0);
        // Read Files data contents
         jbtGetFile.addActionListener(new ActionListener(){
         public void actionPerformed( ActionEvent e) {
                   String FileLoc = Filejta.getText();
                   LocateFile clientsFile;
                   clientsFile = new LocateFile(FileLoc);
                        if (FileLoc != null){
                             String filePath = clientsFile.getFilePath();
                             String filename = clientsFile.getFilename();
                             String DocumentType = clientsFile.getDocumentType();
         public String getFilecontents(){
              String fileString = "\t\tThe file contains the following data:";
         return fileString;
           // Register listener     // Create a new frame to hold the Graph panel
        jbtShowGrph.addActionListener(this);
        grphFrame.add(grph);
        grphFrame.pack();
        grphFrame.setTitle("Chromatogram showing data contained in file \\filename");
      /** Handle the button action */
      public void actionPerformed(ActionEvent e) {
        // Takes data and provides program with CoOrdinates
        int[][]data = createData();
        // Set the data data to graph for display
        grph.showGrph(data);
        // Show the frame
        grphFrame.setVisible(true);
      /** set the data given to the application */
      private int[][] createData() {
           String rawData = jta.getText();
           StringTokenizer tokens = new StringTokenizer(rawData);
           List list = new LinkedList();
           while (tokens.hasMoreElements()){
                String number = "";
                String token = tokens.nextToken();
                for (int i=0; i<token.length(); i++){
                     if (Character.isDigit(token.charAt(i))){
                          number += token.substring(i, i+1);
           int [][]data = new int[list.size()/2][2];
           int index = -2;
           for (int i=0; i<data.length;i++){
                     index += 2;
                     data[0] = Integer.parseInt(
                             (list.get(index).toString()));
                   data[i][1] = Integer.parseInt(
                             (list.get(index +1).toString()));
         return data;
    public static void main(String[] args) {
    GUI frame = new GUI();
    frame.setLocationRelativeTo(null); // Center the frame
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("Clients Data Retrival GUI");
    frame.pack();
    frame.setVisible(true);
    package LineGraph;
    import javax.swing.*;
    import java.awt.*;
    public class Grph extends JPanel {
         private int[][] data;
    /** Set the data and display Graph */
    public void showGrph(int[][] data) {
    this.data = data;
    repaint();
    /** Paint the graph */
    protected void paintComponent(Graphics g) {
    //if (data == null)
         //return; // No display if data is null
    super.paintComponent(g);
    //Find the panel size and bar width and interval dynamically
    int width = getWidth();
    int height = getHeight();
    //int intervalw = (width - 40) / data.length;
    //int intervalh = (height - 20) / data.length;
    //int individualWidth = (int)(((width - 40) / 24) * 0.60);
    ////int individualHeight = (int)(((height - 40) / 24) * 0.60);
    // Find the maximum data. The maximum data
    //int maxdata = 0;
    //for (int i = 0; i < data.length; i++) {
    //if (maxdata < data[i][0])
    //maxdata = data[i][1];
    // x is the start position for the first point
    int x = 30;
    int y = 30;
    //draw a vertical axis
    g.drawLine(20, height - 45, 20, (height)* -1);
    // Draw a horizontal base line4
    g.drawLine(20, height - 45, width - 20, height - 45);
    for (int i = 0; i < data.length; i++) {
    //int Value = i;      
    // Display a line
    //g.drawLine(x, height - 45 - Value, individualWidth, height - 45);
    g.drawLine(data[i][0],data[i][1],data[i+1][0],data[i+1][1]);
    // Display a number under the x axis
    g.drawString((int)(0 + i) + "", (x), height - 30);
    // Display a number beside the y axis
    g.drawString((int)(0 + i) + "", width - 1277, (y) + 900);
    // Move x for displaying the next character
    //x += (intervalw);
    //y -= (intervalh);
    /** Override getPreferredSize */
    public Dimension getPreferredSize() {
    return new Dimension(1200, 900);

  • SQL Query with Distinct and Count is wrong.

    Hello,
    i have another problem with a query.
    Here the Data:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    CREATE      TABLE      TABLE_1
    (       "ORDER_NR"        VARCHAR2 (12)
    ,        "PRIORITY"        VARCHAR2 (2)
    ,        "WO_STATUS"        VARCHAR2 (1)
    ,        "STATUS_DATE"        DATE
    ,       "ART_NR"                      VARCHAR2 (9)
    ,       "DESCRIPTION"      VARCHAR2 (255)
    ,                 "PRICE"                     VARCHAR2 (10)
    CREATE      TABLE      TABLE_2
    (     "ART_NR"            VARCHAR(9)
    ,     "MODELL"              VARCHAR2(10)
    ,     "MANUFACT"         VARCHAR2(20)
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300612',     '12',     'U',        TO_DATE('05-FEB-13 10:22:39','DD-MON-RR HH24:MI:SS'),     '005231987',     '1ST ANNUAL SERVICE',   '5000.2546');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300638',     '05',     'U',        TO_DATE('05-FEB-13 11:38:39','DD-MON-RR HH24:MI:SS'),     '005667821',     '3RD ANNUAL SERVICE',   '5269.7856');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300638',     '12',     'U',        TO_DATE('06-FEB-13 12:38:39','DD-MON-RR HH24:MI:SS'),     '005667821',     '1ST BIENNIAL SERVICE', '1234.4468');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300638',     '12',     'U',        TO_DATE('07-FEB-13 13:38:39','DD-MON-RR HH24:MI:SS'),     '005667821',     '3RD ANNUAL SERVICE',   '4366.7856');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300762',     '12',     'U',        TO_DATE('22-FEB-13 14:55:48','DD-MON-RR HH24:MI:SS'),     '018743356',     '3RD ANNUAL SERVICE',   '4462.8632');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300766',     '12',     'U',        TO_DATE('22-FEB-13 08:32:13','DD-MON-RR HH24:MI:SS'),     '018743356',     '2ND ANNUAL SERVICE',   '8762.6643');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300766',     '05',     'U',        TO_DATE('23-FEB-13 12:32:13','DD-MON-RR HH24:MI:SS'),     '018743356',     '1ST BIENNIAL SERVICE', '3425.6643');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300766',     '12',     'U',        TO_DATE('24-FEB-13 14:32:13','DD-MON-RR HH24:MI:SS'),     '018743356',     '2ND BIENNIAL SERVICE', '6678.6643');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300612',     '12',     'U',        TO_DATE('06-FEB-13 10:22:39','DD-MON-RR HH24:MI:SS'),     '005231987',     '1ST ANNUAL SERVICE',   '5000.2546');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300638',     '05',     'U',        TO_DATE('05-FEB-13 11:38:39','DD-MON-RR HH24:MI:SS'),     '005667821',     '3RD ANNUAL SERVICE',   '5269.7856');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300638',     '12',     'U',        TO_DATE('06-FEB-13 12:38:39','DD-MON-RR HH24:MI:SS'),     '005667821',     '1ST BIENNIAL SERVICE', '1234.4468');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300638',     '12',     'U',        TO_DATE('07-FEB-13 13:38:39','DD-MON-RR HH24:MI:SS'),     '005667821',     '3RD ANNUAL SERVICE',   '4366.7856');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300762',     '12',     'U',        TO_DATE('22-FEB-13 14:55:48','DD-MON-RR HH24:MI:SS'),     '018743356',     '3RD ANNUAL SERVICE',   '4462.8632');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300766',     '12',     'U',        TO_DATE('22-FEB-13 08:32:13','DD-MON-RR HH24:MI:SS'),     '018743356',     '2ND ANNUAL SERVICE',   '8762.6643');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300766',     '05',     'U',        TO_DATE('23-FEB-13 12:32:13','DD-MON-RR HH24:MI:SS'),     '018743356',     '1ST BIENNIAL SERVICE', '3425.6643');
    INSERT      INTO      TABLE_1      (ORDER_NR,              PRIORITY, WO_STATUS,  STATUS_DATE,                                             ART_NR,           DESCRIPTION,            PRICE)
                  VALUES           ('1KKA1Z300766',     '12',     'U',        TO_DATE('24-FEB-13 14:32:13','DD-MON-RR HH24:MI:SS'),     '018743356',     '2ND BIENNIAL SERVICE', '6678.6643');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005231987',     'X-RAY1',          'MANUFACT1');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005231987',     'X-RAY1',          'MANUFACT2');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005231987',     'X-RAY1',          'MANUFACT3');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005231987',     'X-RAY1',          'MANUFACT4');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005231987',     'X-RAY1',          'MANUFACT5');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005231987',     'X-RAY1',          'MANUFACT6');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005667821',     'LASER',          'MANUFACT1');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005667821',     'LASER',          'MANUFACT2');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005667821',     'LASER',          'MANUFACT3');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005667821',     'LASER',          'MANUFACT4');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('018743356',     'VACCUM',          'MANUFACT1');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('018743356',     'VACCUM',          'MANUFACT2');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('018743356',     'VACCUM',          'MANUFACT3');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('018743356',     'VACCUM',          'MANUFACT4');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('018743356',     'VACCUM',          'MANUFACT5');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('018743356',     'VACCUM',          'MANUFACT6');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005231987',     'X-RAY1',          'MANUFACT1');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005231987',     'X-RAY1',          'MANUFACT2');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005231987',     'X-RAY1',          'MANUFACT3');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005231987',     'X-RAY1',          'MANUFACT4');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005231987',     'X-RAY1',          'MANUFACT5');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005231987',     'X-RAY1',          'MANUFACT6');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005667821',     'LASER',          'MANUFACT1');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005667821',     'LASER',          'MANUFACT2');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005667821',     'LASER',          'MANUFACT3');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('005667821',     'LASER',          'MANUFACT4');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('018743356',     'VACCUM',          'MANUFACT1');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('018743356',     'VACCUM',          'MANUFACT2');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('018743356',     'VACCUM',          'MANUFACT3');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('018743356',     'VACCUM',          'MANUFACT4');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('018743356',     'VACCUM',          'MANUFACT5');
    INSERT     INTO      TABLE_2      (ART_NR,            MODELL,         MANUFACT)
                  VALUES           ('018743356',     'VACCUM',          'MANUFACT6');
    COMMIT;And my query:
    SELECT T1.ART_NR
    , T2.MODELL
    , SUM(ROUND(T1.PRICE, 2)) AS TOTAL_PRICE
    , COUNT(*) AS QTY
    , TO_CHAR(T1.STATUS_DATE, 'MON-RR') AS MONTH
    FROM TABLE_1 T1, TABLE_2 T2
    WHERE T1.WO_STATUS = 'U'
    AND T1.ART_NR = T2.ART_NR
    AND TO_CHAR(T1.STATUS_DATE, 'MON-RR') = 'FEB-13'
    GROUP BY T2.MODELL
    , T1.ART_NR
    , TO_CHAR(T1.STATUS_DATE, 'MON-RR')And the result:
    ART_NR      MODELL     TOTAL_PRICE        QTY     MONTH
    018743356 VACCUM     559916.16            96        FEB-13
    005667821 LASER        173936.48            48        FEB-13
    005231987 X-RAY1          120006             24        FEB-13My problem now is, the OTY field ist wrong it should count how often the equipment was in service in FEB-13 and group it by "MODELL" the MANUFACT field is not interesting for me, but this ist my problem, one Modell can have multible Manufacter and so i got a wrong count for my QTY.
    The next step i need is to group the result also by Service type (annual or biennial), like this:
    ART_NR      MODELL     TOTAL_PRICE        QTY     MONTH   SERVICE_TYPE
    018743356 VACCUM      1234.56               4         FEB-13     ANNUAL
    018743356 VACCUM      4423.48               10       FEB-13     BIENNIAL
    005667821 LASER         4783.11               2         FEB-13     ANNUAL
    005667821 LASER         1123.77               22       FEB-13      BIENNIAL
    005231987 X-RAY1        8966.12               6        FEB-13      ANNUAL
    005231987 X-RAY1        7826.44              12        FEB-13      BIENNIALThis values are only out of my head, not the table, only to show what i need.
    Thanks for your help.
    Greets Reinhard

    Hi,
    Here's one way:
    WITH    got_groups  AS
         SELECT  art_nr
         ,     TRUNC (status_date, 'MONTH')     AS month
         ,     CASE
                  WHEN  UPPER (description) LIKE '%ANNUAL%'
                                         THEN  'ANNUAL'
                  WHEN  UPPER (description) LIKE '%BIENNIAL%'
                                         THEN  'BIENNIAL'
              END                    AS service_type
         ,     TO_NUMBER (price)          AS price
         FROM     table_1
         WHERE     status_date     >= DATE '2013-02-01'
         AND     status_date     <  DATE '2013-03-01'
    ,       table_2_summary  AS
         SELECT DISTINCT       art_nr, modell
         FROM               table_2
    SELECT       g.art_nr
    ,       s.modell
    ,       ROUND ( SUM (g.price)
              , 2
              )          AS total_price
    ,       COUNT (*)          AS qty
    ,       g.month
    ,       service_type
    FROM       got_groups       g
    JOIN       table_2_summary  s     ON  s.art_nr  = g.art_nr 
    GROUP BY  g.art_nr
    ,            s.modell
    ,            g.month
    ,       g.service_type
    ;The reason why your aggregates were originally too high is that you have a many-to-many relationship between the tables. The tables are related only by art_nr, but art_nr is not unique in either table. Look at art_nr '005231987', example. There ate 2 rows in table_1 with that art_nr, and 6 rows in table_2 with the same art_nr. If we join on art_nr, then both of the rows in table_1 will match each of the 6 rows in table_2, so the COUNT will be 2 * 6 = 12, and in the SUM, each of the numbers from table_1 will get added 6 times.
    Why is table_2 designed the way it is? Cn there be multiple modells for the same art_nr? If so, what would you want for output? If there can only be 1 modell for each art_nr, then a better design would be to have a table that just had one row per art_nr, and included the modell column, and another table to show which manufacturers produce each art_nr. In this problem, you wouldn't need the manufacturers table, and the other table already has unique art_nrs, so you wouldn't need anything like the sub-query table_2_summary.
    Don't store price in a VARCHAR2 column. Storing NUMBERs in a VARCHAR2 column is just asking for problems. Why not use a NUMBER column instead.
    You'll notice that I used ROUND (SUM ... where you use SUM ( ROUND. The results might be a little different because of rounding errors. ROUND ( SUM only has to call ROUND once per group (5 times in this example) instead of once per row (16 times in this example). The less rounding you do, the less rounding error creeps in. Also, since there are fewer function calls, it's more convenient. (Of course, you'll never notice the difference between calling ROUND 5 times or 16 times, but in a real-life exampe, the difference could be between calling it 50 times or calling it 16000 times.) If you really need to use SUM (ROUND, you can.

  • Help: Problem with data types and classes

    Hi there,
    I'm currently struggling with getting a class to read in data from a file and from that select the correct constructor to use... Basically I read a line in from a file as follows:
    <String Make>:<String model>:<String registrationNumber>:<String engineSize>
    e.g.
    Ford:Focus:HG42EG:1800
    There is an Interface called Car, of which 'Ford' is an implementation along with 'Vauxhall', 'Chrysler', etc...
    From this I wish to construct a new instance of a Ford called Focus with input parameters (RegNumber registration,int engineSize) i.e.
    Car Focus = new Ford(HG4 2EG,1800);So far I can convert the engineSize String into an integer and can construct the RegNumber (a class of mine) but can only get it to construct a Ford by using a switch, i.e:
    switch (modelKey){
    case 'f': new Ford(); break;
    case 'v': new Vauxhall(); break;
    case 't': new Toyota(); break;
    etc...
    Now I do get this to work correctly but I'm concerned that it is not OOP therefore is the way I can get code to convert the String 'Ford' into Car 'Ford'.???
    Many thanks in advance for any advice you can throw my way,
    Leebo

    What is this anyway???
    If Car is an interface you can't create instances of it....No, if Car is an interface, his code should be (depending on what the RegNum constructor looks like:
    Car Focus = new Ford(new RegNum("HG42EG"),1800);It's the same as:
    List someList = new ArrayList();However, he won't be able to use a word read from the file as a variable name "Focus". He'll need a Map:
    Map myCarMap = new HashMap();
    myCarMap.put("Focus", new Ford(new RegNum("HG42EG"), 1800));(Could be defined as "Map<String, Car>" if he wants to use generics.)

  • Using a Comparable Class with Treeset, creating counter in comparable clas

    http://rafb.net/paste/results/jibQzk63.html - comparable http://rafb.net/paste/results/Noahue63.html - loading
    http://rafb.net/paste/results/re1Swn60.html - contents of .txt file * sorry the paste is weird lol.
    Trying to List word count in alphabetical order - Already did that
    Having a counter so it counts the number of time that specfic word appeared in the txt file - This is my problem I don't know where to add the counter in my comparable class so it stores a number and adds everytime that same word appears. ex. "and 7" the word "and" appeared 7 times in the .txt file
    so if some1 could help me, would be apperciated. I've like tried everything and getting the opposite results.

    That's just the issue I'm having. My sample code functions as long as the parameterized type being compared isn't Comparable. For example, changing the type to A<Integer,String> works fine.
    I think I may have discovered why this is the case. By declaring A<Comparable,String>, I am implying that the first parameterized type (call it T) is Comparable<T>. As a result, what I need is an A<Comparable<Comparable>, String>; that is, anything which is comparable must be able to be compared to the object. Since Integer is only Comparable<Integer>, it cannot be compared to all Comparable objects and therefore doesn't meet the requirements.
    I'm not used to looking the other way on the inheritance tree. :)
    The original trouble I had with this came from when I was passing a hash code generator into a piece of source and I needed to compare the hashes. The only guarantee I have regarding the hashes is that they are Comparable and I was putting them in a similar Pair structure. I then wanted to build a comparator to compare them but, since they're Comparable<?>, I can't know to what they can be compared... so I'll have to change the contract on the code. ;)
    Thanks. Cheers. :)

  • Need help in optimizing the query with joins and group by clause

    I am having problem in executing the query below.. it is taking lot of time. To simplify, I have added the two tables FILE_STATUS = stores the file load details and COMM table that is actual business commission table showing records successfully processed and which records were transmitted to other system. Records with status = T is trasnmitted to other system and traansactions with P is pending.
    CREATE TABLE FILE_STATUS
    (FILE_ID VARCHAR2(14),
    FILE_NAME VARCHAR2(20),
    CARR_CD VARCHAR2(5),
    TOT_REC NUMBER,
    TOT_SUCC NUMBER);
    CREATE TABLE COMM
    (SRC_FILE_ID VARCHAR2(14),
    REC_ID NUMBER,
    STATUS CHAR(1));
    INSERT INTO FILE_STATUS VALUES ('12345678', 'CM_LIBM.TXT', 'LIBM', 5, 4);
    INSERT INTO FILE_STATUS VALUES ('12345679', 'CM_HIPNT.TXT', 'HIPNT', 4, 0);
    INSERT INTO COMM VALUES ('12345678', 1, 'T');
    INSERT INTO COMM VALUES ('12345678', 3, 'T');
    INSERT INTO COMM VALUES ('12345678', 4, 'P');
    INSERT INTO COMM VALUES ('12345678', 5, 'P');
    COMMIT;Here is the query that I wrote to give me the details of the file that has been loaded into the system. It reads the file status and commission table to show file name, total records loaded, total records successfully loaded to the commission table and number of records that has been finally transmitted (status=T) to other systems.
    SELECT
        FS.CARR_CD
        ,FS.FILE_NAME
        ,FS.FILE_ID
        ,FS.TOT_REC
        ,FS.TOT_SUCC
        ,NVL(C.TOT_TRANS, 0) TOT_TRANS
    FROM FILE_STATUS FS
    LEFT JOIN
        SELECT SRC_FILE_ID, COUNT(*) TOT_TRANS
        FROM COMM
        WHERE STATUS = 'T'
        GROUP BY SRC_FILE_ID
    ) C ON C.SRC_FILE_ID = FS.FILE_ID
    WHERE FILE_ID = '12345678';In production this query has more joins and is taking lot of time to process.. the main culprit for me is the join on COMM table to get the count of number of transactions transmitted. Please can you give me tips to optimize this query to get results faster? Do I need to remove group and use partition or something else. Please help!

    I get 2 rows if I use my query with your new criteria. Did you commit the record if you are using a second connection to query? Did you remove the criteria for file_id?
    select carr_cd, file_name, file_id, tot_rec, tot_succ, tot_trans
      from (select fs.carr_cd,
                   fs.file_name,
                   fs.file_id,
                   fs.tot_rec,
                   fs.tot_succ,
                   count(case
                            when c.status = 'T' then
                             1
                            else
                             null
                          end) over(partition by c.src_file_id) tot_trans,
                   row_number() over(partition by c.src_file_id order by null) rn
              from file_status fs
              left join comm c
                on c.src_file_id = fs.file_id
             where carr_cd = 'LIBM')
    where rn = 1;
    CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS
    LIBM    CM_LIBM.TXT          12345678                5          4          2
    LIBM    CM_LIBM.TXT          12345677               10          0          0Using RANK can potentially produce multiple rows to be returned though your data may prevent this. ROW_NUMBER will always prevent duplicates. The ordering of the analytical function is irrelevant in your query if you use ROW_NUMBER. You can remove the outermost query and inspect the data returned by the inner query;
    select fs.carr_cd,
           fs.file_name,
           fs.file_id,
           fs.tot_rec,
           fs.tot_succ,
           count(case
                    when c.status = 'T' then
                     1
                    else
                     null
                  end) over(partition by c.src_file_id) tot_trans,
           row_number() over(partition by c.src_file_id order by null) rn
    from file_status fs
    left join comm c
    on c.src_file_id = fs.file_id
    where carr_cd = 'LIBM';
    CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS         RN
    LIBM    CM_LIBM.TXT          12345678                5          4          2          1
    LIBM    CM_LIBM.TXT          12345678                5          4          2          2
    LIBM    CM_LIBM.TXT          12345678                5          4          2          3
    LIBM    CM_LIBM.TXT          12345678                5          4          2          4
    LIBM    CM_LIBM.TXT          12345677               10          0          0          1

  • Please help me with this SQL query

    I am practicing SQL queries and have come across one involving fetching data from 3 different tables.
    The three tables are as below
    <pre>
    Country
    location_id          country
    loc1          Spain
    loc2          England
    loc3          Spain
    loc4          USA
    loc5          Italy
    loc6          USA
    loc7          USA
    </pre>
    <pre>
    User
    user_id location_id
    u1 loc1
    u2 loc1
    u3 loc2
    u4 loc2
    u5 loc1
    u6 loc3
    </pre>
    <pre>
    Post
    post_id user_id
    p1 u1
    p2 u1
    p3 u2
    p4 u3
    p5 u1
    p6 u2
    </pre>
    I am trying to write an SQL query - for each country of users, display the average number of posts
    I understand the logic behind this that we first need to group together all the locations and then the users belonging to one country and then find the average of their posts.
    But, i'm having a difficulty in putting this in SQL form. Could someone please help me with this query.
    Thanks.

    select
    country.country,
    count(*) Totalpostspercountry,
    count(distinct post.user_id) Totaldistincuserspercountry,
    count(*)/count(distinct post.user_id) Avgpostsperuserbycountry
    from
    country, muser, post
    where country.location_id = muser.location_id
    and muser.user_id = post.user_id
    group by country.country
    The output is like this for your sample data - hope this is what you were looking for :)
    COUNTRY,TOTALPOSTSPERCOUNTRY,TOTALDISTINCUSERSPERCOUNTRY,AVGPOSTSPERUSERBYCOUNTRY
    England,1,1,1,
    Spain,5,2,2.5,

  • HT1369 hey, when I connect either my ipod or ipad to itunes I get the promt ' i tunes was unable to load data class information from sync services. Reconnect or try again later'. Can anyone help me with syncing my devices?? Thanks in advance

    Hey, when I connect either my ipod or ipad to itunes I get the prompt 'itunes was unable to load data class information from sync services. Reconnect or try again later. Can anyone help me with syncing my devices?? Thanks in advance

    I am having the same issue, anyone else ?

  • Can anyone help me with a problem i am having with my music on my iPhone 4S. I have put alot of Compilation CDs in my library on iTunes. I download these tracks onto my phone, everything is ok so far. Now, this is what is niggling me and I don.t know how

    Can anyone help me with a problem i am having with my music on my iPhone 4S. I have put alot of Compilation CDs in my library on iTunes. I download these tracks onto my phone, everything is ok so far. Now, this is what is niggling me and I don.t know how to resolve it. This is my problem: 
    Have downloaded for example: Queen – Bohemium Rhapsody from a compilation album as well as a few complete Queen Album CDs into the iTunes library and then put them into playlists,
    When I go onto my phone and select Queen on the MUSIC app using Songs tab at the bottom of the screen it will display all Queen songs and their resective Alum pics, that is all those not in a complilation album, .
    If I know the song title I can select the songs tab and find the song that way,
    I’ve tried fiddling with the settings in the iTunes app by going to ‘get info’ tab and trying to sort the problem out that way but am not having much luck.What I want the phone to do is show, for example all Queens songs including those in compilation albums. Can this be done, would be grateful for any ideas on how it can be done, that is if ic can be done, any ideas
    Thanks for your help

    Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.

  • HT203433 Hi! I am so stumped with having multiple apple ID accounts now when I try to do an update on my iPhoto app it tells me to log into the account I used to purchase that app. I have tried going into my other accounts. Please help.

    Hi! I am so stumped with having multiple Apple ID accounts. I did this not knowing what I was doing and now I can not update my iPhoto app because it tells me to log into the account that I used to purchase it. I thought I was trying to do this but I can't get anywhere.
    Please help!
    Flora

    Hi Florafromco,
    You can view your iTunes Store account and request assistance by following the instructions below:
    iTunes Store & Mac App Store: Seeing your purchase history and order numbers
    http://support.apple.com/kb/ht2727
    I hope this information helps ....
    The following article will provide a little more information regarding using multiple Apple ID's:
    Using your Apple ID for Apple services
    http://support.apple.com/kb/HT4895
    I hope this information helps ....
    Have a great day!
    Have a great day!
    - Judy

  • Can you help I was having problems with my iPod so I restored it but I accidentally set it up as a new iPod is there any way to restore it from an old  backup when I right click iPod in iTunes there isn't one anyway to recover one or find it on computer

    Hi can you help I was having problems with my iPod so I restored it but I
    accidentally set it up as a new iPod is there any way to restore it from an old
    backup when I right click iPod in iTunes there isn't one anyway to recover one
    or find it on computer

    The following says how to restore from backup.
    iOS: How to back up
    If you go to iTunes>Preferences>Devices you can see if you have an iTunes backup. You need one dated before or the exact time you started the restore.

  • Query Issue in Creating a View....Please help me with this query..

    I would like to create a view on this table with four columns
    1. PN#_EXP_DATE
    2. PN#
    3. PN#_EFF_DATE
    4. PN#
    P_S_C     A_C     P     EXP_DT
    21698     13921     1     5/29/2009 3:15:41 PM     
    21698     13921     1     5/29/2009 3:54:57 PM     
    21698     1716656     4     5/29/2009 3:15:41 PM     
    21698     3217     3     5/29/2009 3:15:40 PM     
    21698     3217     3     5/29/2009 3:54:57 PM     
    21698     60559     2     5/29/2009 3:15:41 PM     
    21698     60559     2     5/29/2009 3:54:57 PM     
    I have a trigger on A, which inserts the DML records into B. (Table A and B structure is the almost the same,
                                       where table B will have one extra column exp_dt)
    NOw Table B can have records with same P_S_C and A_C columns and exp_dt will capture the history.
    for example: from the above sample data, let us take first two records..
    P_S_C     A_C     P     EXP_DT
    21698     13921     1     5/29/2009 3:15:41 PM     --- Record 1
    21698     13921     1     5/29/2009 3:54:57 PM     --- Record 2
    from this..
    Note: 1. Table A and Table C can be joined using A.P_S_C and C.R_C to get the start_date.
    2. PN# comes from table D. It contains numbers for the resp. weeks.
    3. PN#_EFF_DATE is the previous immediate previous date for that record in history table (Table B).
    I wanted the data like..
    ---- this is for the second record in the above..
    PN#_EXP_DATE PN# PN#_EFF_DATE PN#
    5/29/2009 3:54:57 PM     214 5/29/2009 3:15:41 PM     214
    ---- this is for the first record in the above..
    PN#_EXP_DATE PN# PN#_EFF_DATE PN#
    5/29/2009 3:54:41 PM     214 ( for this we should query the table C to get the
                        start_date, for this combinatation of P_S_C and A_C in table B
                             where B.P_S_C = C.A_C
                             and that value should be the EFF_DT for this record)
    Please help me with this....
    Thanks in advance..

    Hi All,
    select d.P# as "PN#_EXP_DATE", exp_date
    from daily_prd d, cbs1_assoc_hist b
    where to_char(d.day_date,'MM/DD/YYYY') = to_char(b.exp_date,'MM/DD/YYYY')
    and d.period_type = 'TIMEREPORT';
    This above query gives the output as follows:
    pn#_exp_date exp_date
    214     5/29/2009 3:15:40 PM
    214     5/29/2009 3:15:41 PM
    214          5/29/2009 3:15:41 PM
    214          5/29/2009 3:15:41 PM
    214          5/29/2009 3:54:57 PM
    214          5/29/2009 3:54:57 PM
    214          5/29/2009 3:54:57 PM
    This below is the data from history table (Table B).
    P_S_C     A_C PLACE EXP_DATE
    21698          3217          3     5/29/2009 3:15:40 PM     
    21698          13921          1     5/29/2009 3:15:41 PM     
    21698          1716656          4     5/29/2009 3:15:41 PM     
    21698          60559          2     5/29/2009 3:15:41 PM     
    21698          13921          1     5/29/2009 3:54:57 PM     
    21698          3217          3     5/29/2009 3:54:57 PM     
    21698          60559          2     5/29/2009 3:54:57 PM     
    I got the pn#_exp_date from the Table 'D', for the given exp_date from Table B.
    My question is again....
    CASE - 1
    from the given records above, I need to look for exp_date for the given same P_S_C and A_C.
    in this case we can take the example...
    P_S_C     A_C PLACE EXP_DATE
    21698          3217          3     5/29/2009 3:15:40 PM
    21698          3217          3     5/29/2009 3:54:57 PM
    In this case, the
    pn#_exp_date exp_date     pn#_eff_date eff_date
    214     5/29/2009 3:15:57 PM     < PN# corresponding to the     5/29/2009 3:15:40 PM
                        eff_date .>
                        <Basically the eff_date is
                        nothing but the exp_date only.
                        we should take the immediate before one.
    In this case, our eff_date is '5/29/2009 3:15:40 PM'.
    but how to get this.
    CASE - 2
    from the above sample data, consider this
    P_S_C     A_C PLACE EXP_DATE
    21698     1716656     4     5/29/2009 3:15:41 PM
    In this case, there is only one record for the P_S_C and A_C combination.
    The expected result :
    pn#_exp_date exp_date               pn#_eff_date eff_date
    214     5/29/2009 3:15:41 PM     < PN# corresponding to the     5/29/2009 3:15:40 PM
                        eff_date .>
                   <Basically the eff_date is
                   nothing but the exp_date only.
                        we should take the immediate before one.
    In this case to get the eff_date, we should query the Table 'C', to get the eff_date, which is START_DT column in this table.
    for this join B.P_S_C and C.R_C.
    Hope I am clear now..
    Thanks in advance.....

  • Please help me with the proper query for the below problem

    Hi,
    I have a table RATE which have two columns RT_DATE (date) and RATES(number).
    This table have following data.
    RT_DATE
    RATES
    1-JAN-2007
    7
    2-MAR-2008
    7.25
    5-JAN-2009
    8
    8-NOV-2009
    8.5
    9-JUN-2010
    9
    I wanted to get the rate of interest on 8-DEC-2009.
    Output will be 8.5 as this given date is in between 8-NOV-2009 and 9-JUN-2010. Could you please help me with proper query?
    Regards,
    Aparna S

    Hi,
    That sounds like a job for the LAST function:
    SELECT  MIN (rates) KEEP (DENSE_RANK LAST ORDER BY rt_date) AS eff_rate
    FROM    rate
    WHERE   rt_date < 1 + DATE '2009-12-08'
    MIN above means that, in case of a tie (that is, 2 or more rows with the exact same latest rt_date) the lowest rates from that latest rt_date will be returned.  In rt_date is unique, then it doesn't matter if you use MIN or MAX, but syntax demands that you use some aggregate function there.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for your sample data, and also post the results you want from that data.
    Point out where the statement above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002#9362002

  • Problem with return a ColdFusion query object from a Java class

    Hi!
    I need to return a ColdFusion query object from a Java class
    using a JDBC result set ( java.sql.ResultSet);
    I have tried to pass my JDBC result set in to the constructor
    of the coldfusion.sql.QueryTable class with this code:
    ColdFusion code
    <cfset pra = createObject("java","QueryUtil").init()>
    <cfset newQuery = CreateObject("java",
    "coldfusion.sql.QueryTable")>
    <cfset newQuery.init( pra.getColdFusionQuery () ) >
    My java class execute a query to db and return QueryTable
    Java code (QueryUtil.java)
    import coldfusion.sql.QueryTable; // (CFusion.jar for class
    QueryTable)
    import com.allaire.cfx //(cfx.jar for class Query used from
    QueryTable)
    public class QueryUtil
    public static coldfusion.sql.QueryTable
    getColdFusionQuery(java.sql.ResultSet rs)
    return new coldfusion.sql.QueryTable(rs);
    but when i run cfm page and coldfusion server tries to
    execute : "<cfset pra =
    createObject("java","QueryUtil").init()>" this error appears:
    Object Instantiation Exception.
    An exception occurred when instantiating a java object. The
    cause of this exception was that: coldfusion/sql/QueryTable.
    If i try to execute QueryUtil.java with Eclipse all it works.
    Also I have tried to return java.sql.ResultSet directly to
    coldfusion.sql.QueryTable.init () with failure.
    Do you know some other solution?

    ok
    i print all my code
    pratica.java execute a query to db and return a querytable
    java class
    import java.util.*;
    import java.sql.*;
    import coldfusion.sql.*;
    public class Pratica {
    private HashMap my;
    private String URI,LOGIN,PWD,DRIVER;
    private Connection conn=null;
    //funzione init
    //riceve due strutture converite in hashmap
    // globals
    // dbprop
    public Pratica(HashMap globals,HashMap dbprop) {
    my = new HashMap();
    my.put("GLOBALS",globals);
    my.put("DBPROP",dbprop);
    URI = "jdbc:sqlserver://it-bra-s0016;databaseName=nmobl";
    LOGIN = "usr_dev";
    PWD = "developer";
    DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    try{
    // Carico il driver JDBC per la connessione con il database
    MySQL
    Class.forName(DRIVER);
    /* Connessione alla base di dati */
    conn=DriverManager.getConnection(URI,LOGIN,PWD);
    if(conn!=null) System.out.println("Connection Successful!");
    } catch (ClassNotFoundException e) {
    // Could not find the database driver
    System.out.print("\ndriver non trovato "+e.getMessage());
    System.out.flush();
    catch (SQLException e) {
    // Could not connect to the database
    System.out.print("\nConnessione fallita "+e.getMessage());
    System.out.flush();
    //funzione search
    //riceve un hash map con i filtri di ricerca
    public QueryTable search(/*HashMap arg*/) {
    ResultSet rs=null;
    Statement stmt=null;
    QueryTable ret=null;
    String query="SELECT * FROM TAN100pratiche";
    try{
    stmt = conn.createStatement();// Creo lo Statement per
    l'esecuzione della query
    rs=stmt.executeQuery(query);
    // while (rs.next()) {
    // System.out.println(rs.getString("descrizione"));
    catch (Exception e) {
    e.printStackTrace();
    try {
    ret = Pratica.RsToQueryTable(rs);
    } catch (SQLException e) {
    e.printStackTrace();
    this.close();
    return(ret);
    // ret=this.RsToQuery(rs);
    // this.close(); //chiude le connessioni,recordset e
    statament
    //retstruct CF vede HashMap come struct
    //METODO DI TEST
    public HashMap retstruct(){
    return(my);
    //conversione resultset to querytable
    private static QueryTable RsToQueryTable(ResultSet rs)
    throws SQLException{
    return new QueryTable(rs);
    //chiura resultset statament e connessione
    private void close(){
    try{
    conn.close();
    conn=null;
    catch (Exception e) {
    e.printStackTrace();
    coldfusion code
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN">
    <html>
    <head>
    <title>Test JDBC CFML Using CFScript</title>
    </head>
    <body>
    <cftry>
    <cfset glb_map =
    createObject("java","java.util.HashMap")>
    <cfset dbprop_map =
    createObject("java","java.util.HashMap")>
    <cfset glb_map.init(glb)> <!---are passed from
    another page--->
    <cfset dbprop_map.init(glb["DBPROP"])>
    <cfset pra =
    createObject("java","Pratica").init(glb_map,dbprop_map)>
    <cfset ourQuery
    =createObject("java","coldfusion.sql.QueryTable").init(pra.search())>
    <cfcatch>
    <h2>Error - info below</h2>
    <cfdump var="#cfcatch#"><cfabort>
    </cfcatch>
    </cftry>
    <h2>Success - statement dumped below</h2>
    <cfdump var="#ourQuery#">
    </body>
    </html>
    error at line <cfset pra =
    createObject("java","Pratica").init(glb_map,dbprop_map)>
    An exception occurred when instantiating a java object. The
    cause of this exception was that: coldfusion/sql/QueryTable.
    -----------------------------------------------------------------------

  • Hi Everyone...Please help me with this query...!

    Please Help me with this doubt as I am unable to understand the logic...behind this code. It's a begineer level code but I need to understand the logic so that I am able to grasp knowledge. Thank you all for being supportive. Please help me.
    //Assume class Demo is inherited from class SuperDemo...in other words class Demo extends SuperDemo
    //Volume is a method declared in SuperDemo which returns an integer value
    //weight is an integer vairable declared in the subclass which is Demo
    class Example
         public static void main(String qw[])
              Demo ob1=new Demo(3,5,7,9);
    //Calling Constructor of Demo which takes in 4 int parameters
              SuperDemo ob2=new SuperDemo();
              int vol;
              vol=ob1.volume();
              System.out.println("Volume of ob1 is " + vol);
              System.out.println("Weight of ob1 is " + ob1.weight);
              System.out.println();
              ob2=ob1;
    }Can someone please make me understand --- how is this possible and why !
    If the above statement is valid then why not this one "System.out.println(ob2.weight);"
    Thanks Thanks Thanks!

    u see the line wherein I am referencing the objectof
    a subclass to the superclass...right? then why we
    can't do System.out.println(ob2.weight)?You need to distinguish two things:
    - the type of the object, which determines with the
    object can do
    - the type of the reference to the object, which
    determines what you see that you can do
    Both don't necessarily have to match. When you use a
    SuperDemo reference (obj2) to access a Demo instance
    (obj1), for all you know, the instance behind obj2 is
    of type SuperDemo. That it's in reality of type Demo
    is unknown to you. And usually, you don't care -
    that's what polymorphism is about.
    So you have a reference obj2 of type SuperDemo.
    SuperDemo objects don't have weight, so you don't see
    it - even though it is there.So from ur explanation wat I understand is - Even though u reference a subclass object to a superclass, u will only be able to access the members which are declared in the superclass thru the same...right
    ?

Maybe you are looking for

  • Fetching international characters from Clob

    Hi, I am trying to fetch hungarian characters from Clob data. I tried reading the Character Stream returned by Clob.getCharacterStream() in linux and it returns junk characters for those but the same works well with windows. I guess its picking up th

  • Reports Runtime - Settings in Designer 9i

    Hi. When executing Reports Runtime, through Repository Reports (Designer 9i) and the program call the browser. I tried to alter General Settings, but it didn't advance I tried to alter registration variables and also without success. Did anybody alre

  • Apple does not recognize my birthday

    Apple keeps sending me password reset by E Mail but the Email never reaches my computer.

  • Logitech Mouse - Right-click won't show context menu - only app switcher

    I use a Logitech MX 600 mouse. In LCC, I've set the Right Button to Click as the assigned action and Right Click as the action performed. When I click the right button, it shows the app switcher. I can see the context menu if I Control - Right Click.

  • Expected ship date 10/7

    I am a long-time Sprint customer. I recently decided to switch to Verizon when the iPhone 5S came out. I got online on the 20th, ported my number over from Sprint and made the switch. I got a preorder confirmation email with the order number included