Results 1 to 4 of 4
  1. #1
    javamula is offline Member
    Join Date
    Sep 2009
    Posts
    22
    Rep Power
    0

    Default Jtable Sum of Sales based on criteria.

    Please help which function in Jtable / SQL in order to get the Sales total based on the criteria of EmployeeID and ProductID?

    basically i would like to do as the following:

    1. Employee A,sales xxx, Product 1, sales YYY, product 2...
    2. Employee B....

    TQ.

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    806
    Rep Power
    6

    Default

    U can refere sql forums for these queries.
    But,anyway u can use group by clause for doing this..
    Gothru this link

    SQL: GROUP BY Clause
    Ramya:cool:

  3. #3
    javamula is offline Member
    Join Date
    Sep 2009
    Posts
    22
    Rep Power
    0

    Default

    Dear Ramya,

    thank you for the advice...how to put that into the Jtable...or at least i can System.out.println( of the result);

    as i have the following code...
    Java Code:
    ....
    
    protected void getTableContents (Connection conn,
    					 String tableName)
    			throws SQLException {
    
    DatabaseMetaData meta = conn.getMetaData();
    String sql = "SELECT * SUM Total as Total Sales FROM SalesGroup GROUP BY Product ID
    
    Statement st = conn.createStatement();
    ResultSet res = st.executeQuery(sql);
    TQ.

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    1.) Don't pass a connection into that method. Create the connection in that method, use it and close it in a finally block.
    2.)You need to read Sun's tutorial on the TableModels section to learn how to display data in a JTable.
    Last edited by r035198x; 10-05-2009 at 07:14 PM.

Similar Threads

  1. Hibernate Criteria
    By stunaz in forum JDBC
    Replies: 0
    Last Post: 12-02-2008, 03:20 PM
  2. Sales-n-Stats 2.1 Beta
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-26-2007, 12:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •