Need a query for access tables

Hi
I need a query , help please:
table1:
id              description                  serial                    
1                des1                           ser1
2                des2                           ser2
3                des3                           ser3
table2:
id            id1(id of table1)                date                
stat
1              1                                      
2001                 A
2              1                                      
2008                 N
3              2                                      
2010                 A
4              1                                      
2012                 F
==============
i need this data structure: (stat column must return for maximum date of id1 from table2)
id(from table1)            serial(from table1)                  stat(from table2)
1                                    ser1                
                       2012
2                                    ser2             
                          2010
3                                    ser3             
                           Null

maybe you can try this.
declare @t1 table
(id int,[description] varchar(50),serial varchar(10))
declare @t2 table
(id int,id1 int,[date] char(4),stat char(10))
insert into @t1 values
(1,'des1','ser1'),
(2,'des2','ser2'),
(3,'des3','ser3')
insert into @t2 values
(1,1,'2001','A'),
(2,1,'2008','N'),
(3,2,'2010','A'),
(4,1,'2012','F')
select a.id,a.serial,max(b.date)
from @t1 a
left join @t2 b
on a.id = b.id1
group by a.id,a.serial
| SQL PASS Taiwan Page |
SQL PASS Taiwan Group
|
My Blog

Similar Messages

  • Need a query for export table data .....

    Hi,
    I need a query for exporting the data in a table to a file.
    Can anyone help me ?
    Thanking You
    Jeneesh

    SQL> spool dept.txt
    SQL> select * from dept;
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    SQL> spool off
    SQL> ed dept.txt

  • Need a query for monthly Report

    Hello All,
    I need a query for monthly report,
    comp_code
    emp_id
    dept_id
    work_day
    100
    A100
    MECH
    01/01/2013
    100
    A100
    MECH
    02/01/2013
    100
    A100
    MECH
    03/01/2013
    100
    A100
    MECH
    04/01/2013
    100
    A100
    MECH
    05/02/2013
    100
    A100
    MECH
    08/02/2013
    100
    A100
    MECH
    09/02/2013
    100
    A100
    MECH
    10/02/2013
    100
    A100
    MECH
    12/05/2013
    100
    A100
    MECH
    13/05/2013
    100
    A101
    CIV
    01/04/2013
    100
    A101
    CIV
    02/04/2013
    100
    A101
    CIV
    03/04/2013
    100
    A101
    CIV
    04/04/2013
    100
    A101
    CIV
    06/04/2013
    100
    A101
    CIV
    06/06/2013
    100
    A101
    CIV
    07/06/2013
    100
    A101
    CIV
    08/06/2013
    100
    A101
    CIV
    09/06/2013
    100
    A101
    CIV
    10/06/2013
    100
    A101
    CIV
    11/12/2013
    100
    A101
    CIV
    12/12/2013
    100
    A101
    CIV
    13/12/2013
    100
    A101
    CIV
    14/12/2013
        Dear friends this the sample table of my report.In which table has contain list of  employees with their working days(actual table has contain almost 5laks of records).
    suppose user choose the date between 01/01/2013 and 31/12/2013 then the result should be like this.
    comp_code
    emp_id
    dept_id
    month
    Total_work
    100
    A100
    MECH
    JANUARY
    4
    100
    A100
    MECH
    FEBRUARY
    2
    100
    A100
    MECH
    MARCH
    0
    100
    A100
    MECH
    APRIL
    0
    100
    A100
    MECH
    MAY
    2
    100
    A100
    MECH
    JUNE
    0
    100
    A100
    MECH
    JULY
    0
    100
    A100
    MECH
    AUGUST
    0
    100
    A100
    MECH
    SEPTEMBER
    0
    100
    A100
    MECH
    OCTOBER
    0
    100
    A100
    MECH
    NOVEMBER
    0
    100
    A100
    MECH
    DECEMBER
    0
    100
    A101
    CIV
    JANUARY
    0
    100
    A101
    CIV
    FEBRUARY
    0
    100
    A101
    CIV
    MARCH
    0
    100
    A101
    CIV
    APRIL
    5
    100
    A101
    CIV
    MAY
    0
    100
    A101
    CIV
    JUNE
    5
    100
    A101
    CIV
    JULY
    0
    100
    A101
    CIV
    AUGUST
    0
    100
    A101
    CIV
    SEPTEMBER
    0
    100
    A101
    CIV
    OCTOBER
    0
    100
    A101
    CIV
    NOVEMBER
    0
    100
    A101
    CIV
    DECEMBER
    4

    Hi,
    If you want the output to include months where no work was done (with 0 in the total_work column) then you need to outer-join a "table" that has one row per month, and make it a partitioned outer join:
    WITH  got_end_points   AS
       SELECT  TRUNC (MIN (work_day), 'MONTH')   AS first_month
       ,       TRUNC (MAX (work_day), 'MONTH')   AS last_month
       FROM    table_x
    ,   all_months   AS
       SELECT  ADD_MONTHS (first_month, LEVEL - 1)   AS a_month
       ,       ADD_MONTHS (first_month, LEVEL)       AS next_month
       FROM    got_end_points
       CONNECT BY  LEVEL <= 1 + MONTHS_BETWEEN (last_month, first_month)
    SELECT    t.comp_code
    ,         t.emp_id
    ,         t.dept_id
    ,         m.a_month
    ,         COUNT (t.work_day) AS total_work
    FROM             all_months  m
    LEFT OUTER JOIN  table_x     t  PARTITION BY (t.comp_code, t.emp_id, t.ept_id)
                                    ON   t.work_day  >= a.a_month
                                    AND  t.work_day  <  a.next_month
    GROUP BY  t.comp_code
    ,         t.emp_id
    ,         t.dept_id
    ,         m.a_month
    ORDER BY  t.comp_code
    ,         t.emp_id
    ,         t.dept_id
    ,         m.a_month
    As posted, this include every month that is actually in the table.  You can change the first sub-query if you want to enter first and last months.
    I hope this answers your question.
    If not, post  a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Point out where the query above is giving the wrong results, and explain, using specific examples, how you get the correct results from the given data in those places.  If you changed the query at all, post your code.
    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

  • Data area for accessing table is too small., error key: RFC_ERROR_SYSTEM_FA

    Hi all,
    I build a java applicatio to call a sap function.
    This FM have only an import parameter as structure, the last field of this structure is 16000 characters long.
    When I start the application if the long field is empty all works fine, but if I fill it the java compiler send me this runtime error:
    [code]
    Exception in thread "main" com.sap.aii.proxy.framework.core.BaseProxyException:
    Data area for accessing table is too small.,
    error key: RFC_ERROR_SYSTEM_FAILURE
         at com.sap.aii.proxy.framework.core.AbstractProxy.send$(AbstractProxy.java:150)
         at bi9032.BI_9032_PortType.zhr_Bi_9032(BI_9032_PortType.java:16)
         at bi9032.Startapp.main(Startapp.java:50)
    [/code]
    Any one can me explain the problem?
    It's possible that I can't pass a large data quantity?
    thanks and regards,
    enzo
    Message was edited by: Enzo Porcasi

    I understood that it's a sap problem,
    so I will write in the abap forum,
    bye
    enzo

  • Need coding support for Accessing MYSQL stored procedure from java

    Hi every one,
    I need coding support for accessing Mysql stored procedure from java and JSP.
    Please help me
    pranav

    You'd better have a recent version of MySQL, because earlier ones didn't support stored procs.
    If your MySQL and driver support stored procs, maybe you just need a JDBC stored proc tutorial.
    %

  • Tuning SQL Query for base tables

    Hi,
    Can any please help me to tune the below query...... there is full table scan for po_action_history table
    SELECT DISTINCT
         DECODE(hr.full_name,'Default Buyer, Purchasing','PCH',
    'Default Buyer, Travel','TRV',
    'Purchase Order, Rapid','RPO',
    'Data Interchange, Electronic','EDI',fuser1.user_name) BUYER_ID,
    poa.attribute1 BUYER_GROUP,
         poa.attribute2 BUYER_SUBGROUP
    FROM      po.po_action_history ac1,
         po.po_headers_all ph,
         po.po_agents poa,
         hr.per_all_people_f hr,
         applsys.fnd_user fuser1
    WHERE ph.po_header_id = ac1.object_id
    AND      ac1.object_type_code = 'PO'
    AND      ac1.action_code = 'APPROVE'
    AND      sequence_num =(SELECT MIN(ac2.sequence_num)
                   FROM po.po_action_history ac2,
                        applsys.fnd_user fuser2
    WHERE ph.po_header_id = ac2.object_id
    AND      ac2.object_type_code = 'PO'
    AND      ac2.action_code = 'APPROVE'
    AND      ac2.last_updated_by = fuser2.user_id)
    --AND  ac1.last_updated_by = fuser1.user_id
    AND      ph.agent_id = poa.agent_id
    AND      ph.agent_id = hr.person_id
    AND      hr.person_id = fuser1.employee_id
    AND      hr.effective_end_date > sysdate
    AND trunc(ac1.last_update_date) between '01-JAN-08' and '07-JAN-08'
    ORDER BY poa.attribute1
    Explain Plan
    PLAN_TABLE_OUTPUT
    Plan hash value: 3325319312
    Id Operation Name Rows
    Bytes Cost (%CPU) Time
    PLAN_TABLE_OUTPUT
    | 0 | SELECT STATEMENT | | 27 |
    2754 | 38963 (3) | 00:07:48 |
    | 1 | SORT UNIQUE | | 27 |
    2754 | 38962 (3) | 00:07:48 |
    |* 2 | FILTER | | |
    | | |
    |* 3 | HASH JOIN | | 37 |
    3774 | 36308 (3) | 00:07:16 |
    PLAN_TABLE_OUTPUT
    | 4 | TABLE ACCESS BY INDEX ROWID | FND_USER | 1 |
    13 | 2 (0) | 00:00:01 |
    | 5 | NESTED LOOPS | | 37 |
    3293 | 36303 (3) | 00:07:16 |
    | 6 | NESTED LOOPS | | 88 |
    6688 | 36180 (3) | 00:07:15 |
    | 7 | NESTED LOOPS | | 88 |
    PLAN_TABLE_OUTPUT
    3960 | 35916 (3) | 00:07:11 |
    |* 8 | TABLE ACCESS FULL | PO_ACTION_HISTORY | 2110 |
    71740 | 32478 (3) | 00:06:30 |
    | 9 | TABLE ACCESS BY INDEX ROWID | PO_HEADERS_ALL | 1 |
    11 | 2 (0) | 00:00:01 |
    |* 10 | INDEX UNIQUE SCAN | PO_HEADERS_U1 | 1 |
    | 1 (0) | 00:00:01 |
    PLAN_TABLE_OUTPUT
    | 11 | SORT AGGREGATE | | 1 |
    36 | | |
    | 12 | NESTED LOOPS | | 1 |
    36 | 6 (0) | 00:00:01 |
    |* 13 | TABLE ACCESS BY INDEX ROWID| PO_ACTION_HISTORY | 1 |
    31 | 6 (0) | 00:00:01 |
    |* 14 | INDEX RANGE SCAN | PO_ACTION_HISTORY_N1 | 5 |
    | 3 (0) | 00:00:01 |
    PLAN_TABLE_OUTPUT
    |* 15 | INDEX UNIQUE SCAN | FND_USER_U1 | 1 |
    5 | 0 (0) | 00:00:01 |
    | 16 | TABLE ACCESS BY INDEX ROWID | PER_ALL_PEOPLE_F | 1 |
    31 | 3 (0) | 00:00:01 |
    |* 17 | INDEX RANGE SCAN | PER_PEOPLE_F_PK | 1 |
    | 2 (0) | 00:00:01 |
    |* 18 | INDEX RANGE SCAN | FND_USER_N1 | 1 |
    PLAN_TABLE_OUTPUT
    | 1 (0) | 00:00:01 |
    | 19 | TABLE ACCESS FULL | PO_AGENTS | 183 |
    2379 | 4 (0) | 00:00:01 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
    2 - filter(TO_DATE('01-JAN-08')<=TO_DATE('07-JAN-08'))
    3 - access("PH"."AGENT_ID"="POA"."AGENT_ID")
    8 - filter("AC1"."ACTION_CODE"='APPROVE' AND "AC1"."OBJECT_TYPE_CODE"='PO'AND
    TRUNC(INTERNAL_FUNCTION("AC1"."LAST_UPDATE_DATE"))>='01-JAN-08' AND
    TRUNC(INTERNAL_FUNCTION("AC1"."LAST_UPDATE_DATE"))<='07-JAN-08')
    10 - access("PH"."PO_HEADER_ID"="AC1"."OBJECT_ID")
    PLAN_TABLE_OUTPUT
    filter("SEQUENCE_NUM"= (SELECT MIN("AC2"."SEQUENCE_NUM") FROM "APPLSYS"."FND_USER"
    "FUSER2","PO"."PO_ACTION_HISTORY" "AC2" WHERE "AC2"."OBJECT_ID"=:B1 AND "AC2"."ACTION_CODE"='APPROVE'
    AND "AC2"."OBJECT_TYPE_CODE"='PO' AND "AC2"."LAST_UPDATED_BY"="FUSER2"."USER_ID"))
    13 - filter("AC2"."ACTION_CODE"='APPROVE' AND "AC2"."OBJECT_TYPE_CODE"='PO')
    14 - access("AC2"."OBJECT_ID"=:B1)
    PLAN_TABLE_OUTPUT
    15 - access("AC2"."LAST_UPDATED_BY"="FUSER2"."USER_ID")
    17 - access("PH"."AGENT_ID"="PERSON_ID" AND "EFFECTIVE_END_DATE">SYSDATE@!)
    filter("EFFECTIVE_END_DATE">SYSDATE@!)
    18 - access("PERSON_ID"="FUSER1"."EMPLOYEE_ID")
    Thanks

    Hi,
    any help for the above issue.

  • Join query for three tables

    Hi i have got this query that is a join of two tables but i need join for three tables i need the extended query
    select aauthlname aauthlnam aauthfname aauthfnam aisbn btitle
      from ( bsauthors as a inner join bsbook as b on aisbn = bisbn )
      into corresponding fields of table books
      where aauthlname like authorlname or aauthfname like authorfname
      order by aauthlname aauthfname a~isbn.

    Hi pavan
    Plz try the following querry for joins on three tables :
    " Customize it to ur requirements and tablenames
    Parameters : b type mara-matnr.
    select xmatnr xmtart xmatkl ywerks ylgort zmaktx
    into corresponding fields of table itab
         from (  ( mara as x inner join mard as y on xmatnr = ymatnr )
    inner join makt as z on xmatnr = zmatnr ) where x~matnr = a and
    y~werks
    = b .
    Plz see that there is atleast one field common between the three tables u want to use.
    Regards
    Pankaj

  • Help needed in query for Materialized View

    Hi,
    I want to create a materialized view which has some precalcultaed values.
    I have four dimension tables out of which one is a Time Dimension table with levels as Year->Quarter->Month.
    The precalculations are the moving averages and cummulative values of Sales Amt on the dimension values over a period of 4 Months.
    The dimension tables are Clients, Products, Channel, Time.
    Fact Table is Sales_Fact which will have the sales amount for different members of the dimension.
    Since my fact table is very huge, i want to create a materialized view where i could store the required calculated measures, here Moving Average of Sales Amt for each Client, Product, Channel dimensions over a period of 4 Months.
    Can anybody help with writing the query for this..Any help in this regard will be appreciated..
    Please give me suggestions for this..

    Check this link.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/aggreg.htm#sthref1612
    Regards
    Raj

  • How to query for two tables

    Hi,
    I have this problem, How can query a two table?
    Table A ->  Table B
    id               table-a_id
    name          table_b_name
    the relationship is one-to-many
    How can I get the result?
    Hope my question make sense
    cheers.
    thanks a lot.

    I bet you have more luck looking for an answer in a SQL forum.

  • Need a Query for getting ItemCost from PO Vendor wise

    Hi,Experts We are not maintain different price list for  some particular items , We raised the PO for Multiple vendors with differnt price for the same material. We need a query to find the Item cost with Various Vendor .
    I need the query in the following format
    Po Number, Vendor Name,Item Name, Item Description,Qty, Price,Tax.
    Thanks
    Kamal

    Hi,
    Check this query which looks for the Item doctype Purchase Order and brings the data accordingly :
    select t0.docnum as 'PO Number', t0.CardName as 'Vendor name', t1.itemcode as 'Item Name',
    t1.Dscription as 'Item Description', t1.quantity as 'QTY', t1.Price as 'Price',
    t1.vatsum as 'Tax Amount'
    from OPOR t0 inner join POR1 t1 on t0.docentry = t1.docentry
    where t0.doctype ='I'
    Group by t1.itemcode, t1.Dscription, t0.docnum,
    t0.cardname, t1.quantity, t1.Price, t1.vatsum
    Order by t1.Itemcode
    Check if it helps.
    Kind Regards,
    Jitin
    SAP Business One Forum Team

  • Client Adapter for Access table connection

    Were is possible to get just the portion of Oracle Open Client Adapter for ODBC V 6.0.5.35 that enable to establishe a connection with Access table?

    Cisco broadens WLAN offerings
    By John Cox
    Network World Fusion, 11/12/03
    Cisco Wednesday will announce a series of products and product
    improvements to bolster its wireless LAN offerings, including
    additional software that shifts WLAN features into other parts
    of the corporate net.
    The announcement will include, according to a source familiar
    with Cisco's plans:
    * Cisco's first 54M bit/sec 802.11g radios for its access
    points.
    * A new client adapter card that can work with 802.11a, 11b, or
    11g access points.
    * A new version of its IOS network operating system, adapted for
    the model 1100 and 1200 access points.
    * A new software version for the CiscoWorks Wireless LAN
    Solutions Engine, which is a server for administering access
    points.
    Last June, Cisco unveiled a WLAN strategy called Structured
    Wireless-Aware Network (SWAN). The idea behind SWAN is to
    distribute WLAN functions to various devices in the net, as
    appropriate. Cisco officials say some functions are best done on
    access points, and the adaptation of IOS for these devices makes
    them highly programmable, and visible to other Cisco network
    resources, such as network management and network security
    products.
    Other functions have been shifted to the Wireless LAN Solutions
    Engine (WLSE or "willsee" to insiders). Still others will be
    shifted gradually to Cisco's wireline switches and routers, as
    IOS is updated. The first release of "wireless aware" IOS will
    be sometime in 2004, Cisco said.
    For the full story, please go to:
    <http://www.nwfusion.com/news/2003/1112ciswlan.html?nl>

  • Need sql query for typical scenario

    Hello Champs,
    I have a scenario where I am suppose to fetch data from a schema which is developed by other team ... (there are no primary keys even)
    the table structure is -
    Column A Column B Column C Column D
    1 h 6 u
    1 h 7 u
    1 h 8 u
    2 g 9 i
    2 g 0 i
    2 g 7 i
    3 t 3 h
    3 t 4 h
    3 t 5 i
    and my output should be exactly like :
    1 h 6,7,8 u
    2 g 9,0,7 i
    3 t 3,4 h
    so basically I want comma separated values for column c where remaining column values are same ...
    is it possible to achieve this result via SQL?? if not then what is the other solution??
    Please help .. I am working in IST and need solution urgently for this .. please help .
    TIA,
    Regards,
    Chintan

    if you have 11g
    WITH t AS (SELECT 1 cola,
                      'h' colb,
                      6 colc,
                      'u' cold
                 FROM DUAL
               UNION
               SELECT 1,
                      'h',
                      7,
                      'u'
                 FROM DUAL
               UNION
               SELECT 1,
                      'h',
                      8,
                      'u'
                 FROM DUAL
               UNION
               SELECT 2,
                      'g',
                      9,
                      'i'
                 FROM DUAL
               UNION
               SELECT 2,
                      'g',
                      0,
                      'i'
                 FROM DUAL
               UNION
               SELECT 2,
                      'g',
                      7,
                      'i'
                 FROM DUAL
               UNION
               SELECT 3,
                      't',
                      3,
                      'h'
                 FROM DUAL
               UNION
               SELECT 3,
                      't',
                      4,
                      'h'
                 FROM DUAL
               UNION
               SELECT 3,
                      't',
                      5,
                      'i'
                 FROM DUAL)
      SELECT cola, colb,  listagg (colc, ',') WITHIN GROUP (ORDER BY colc) colc, cold
        FROM t
    GROUP BY cola, colb, cold
    COLA     COLB     COLC     COLD
    1     h     6,7,8     u
    2     g     0,7,9     i
    3     t     3,4     h
    3     t     5     i

  • Cannot connect and run query for Access database

    Hi,
    I have a html file and a servlet file which contains code to connect to a database. I also have a sales database with customer table along with other tables in Access. I have created a DSN in Windows named sales which connects to the sales database. Now, when I am running the html form, the servlet does not run the query "Select * from Customer". It seems it cannot make any connection to the database.
    Any help is appreciated. I am very new to JDBC technology. Thanks.
    HTML FORM CODE:
    <html>
    <head><title>Sales</title></head>
    <body>
    <form action="http://localhost:8100/servlet/SalesServlet" method=POST>
    <strong>Select:</strong>
    <textarea cols=50 rows=8 name=select></textarea><p>
    <input type=submit value="Query">
    <input type=reset>
    </form></body></html>
    SALESSERVLET CODE:
    //Copyright (c) 2000, Art Gittleman
    //This example is provided WITHOUT ANY WARRANTY either expressed or implied.
    /* Queries the Sales database. Needs to be modified
    * to use metadata to correctly output the result set.
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import sun.jdbc.odbc.JdbcOdbcDriver;
    public class SalesServlet extends HttpServlet {
    Connection con;
    Statement stmt;
    public void init(ServletConfig sc) throws ServletException {
    super.init(sc);
    try{
    new JdbcOdbcDriver();
    String url = "jdbc:odbc:Sales";
    String user = "";
    String password = "";
    con = DriverManager.getConnection(url, user, password);
    stmt = con.createStatement();
    }catch (Exception e) {
    e.printStackTrace();
    System.exit(1);
    public void doGet(HttpServletRequest req,
    HttpServletResponse resp)
    throws ServletException, IOException {
    resp.setContentType("text/html");
    PrintWriter out = resp.getWriter();
    try{
    String query = req.getParameter("select");
    ResultSet rs = stmt.executeQuery(query);
    ResultSetMetaData rsMetaData = rs.getMetaData();
    int cols = rsMetaData.getColumnCount();
    while(rs.next()) {
    String s = "";
    for(int i=1; i<=cols; i++)
    s += rs.getString(i) + ' ';
    s += "<br>";
    out.println(s);
    }catch(Exception e) {
    e.printStackTrace();
    out.close();
    public void doPost(HttpServletRequest req,
    HttpServletResponse resp)
    throws ServletException, IOException {
    doGet(req,resp);
    }

    String url = "jdbc:odbc:Sales";
    String user = "";
    String password = "";
    con = DriverManager.getConnection(url, user, password);This might be causing your problem, but not sure. Since you don't need a username or password for the ODBC connection, you can just use
    con = DriverManager.getConnection(url);
    The username and password aren't needed, so you can just use the above call instead. Perhaps the ODBC is trying to find a user called "" with a password "" and puking on itself, who knows... but you should post whatever exceptions or specific problems you're having that make you think you're not connecting.

  • Query for 3 tables.

    Hi,
    I need to write a SELECT statement that returns one row for each customer that has orders with the following columns:
    ======================================================================
    Email addresses from Customers Table
    Sum of the Item Price in the OrdersItems table multiplied by the quantity in the
    OrderItems table
    Sum of the discount amount column in the OrderItems table multiplied by the quantity in the OrderItems Table.
    Sort the results set in the descending sequence by the item price total for each customer.
    ===================================================================
    Customers table has no connection with Orderitems table, so it has to go through ORDERS table.  I have written the following query. Can someone check and give me a feed back? It is not giving me the correct output. This should be the output:
    Email address                                        
    ItemPriceTotal                                DiscountAmountTotal
    [email protected]                   4131.00                                             
    1830.30
    etc, etc........
    My code is not adding the above columns correctly. I have tried SUM for Total columns but gives me errors:
    SELECT EmailAddress, ItemPrice * Quantity AS ItemPriceTotal, DiscountAmount * Quantity AS DiscountAmountTotal
    FROM
    Customers
     JOIN ORDERS
    ON CUSTOMERS.CustomerID = Orders.CustomerID  ----Joins Orders with Customers
    JOIN OrderItems
    ON Orders.OrderID = OrderItems.OrderID; ------ Joins Orders with OrderItems
    ----ORDER BY EmailAddress,ItemPriceTotal;  ( tried Order by, but output is not correct)

    Thank you for your help. I really appreciate it. My output should look like this, but my query is not adding the ItemPriceTotal and DiscountAmountTotal:
    Results:
    EmailAddress
    ItemPriceTotal
    DiscountAmountTotal
    [email protected]
    4131.00
    1830.39
    [email protected]
    2398.00
    719.40
    [email protected]
    2198.98
    659.70
    [email protected]
    998.00
    209.70
    [email protected]
    799.99
    120.00
    [email protected]
    489.99
    186.20
    [email protected]
    299.00
    0.00

  • Query for Empty Tables.

    Hi All,
    Can someone tell me a Query to find out "EMPTY TABLES i.e. Tables having no Rows" in Oracle 8i ?
    I tried on Google, but results are not satisfactory, may be due to 8i version.
    Please guide me.
    Regards.

    982164 wrote:
    Hi Hoek,
    Actually we upgraded our database to 11g.
    We imported our data from 8i to 11gr2 by the utility IMP successfully.
    It imported our data 100% i.e. when we import 8i dmp data into 11g, there is never problem.
    Problem is arises now when we further use IMP/EXP utility in 11g.So everything in Oracle 8 is working the way you expect. The fact that you also have an Oracle 8 database has nothing to do with this problem. Is that what you're saying?
    When we run EXP utlity in 11g, it doesn't export empty tables.If the problem is entirely in Oracle 11, then you should be able to use something like XMLQUERY to find the 0-row tables, if you really need to. (I think you don't.)
    EXP can export tables with 0 rows. I just tried it in Oracle 11, and part of the feedback I got was:
    . . exporting table                       ZIPCODES          0 rows exported
    . . exporting table                  ZONEORDER_TBL          5 rows exported
    . . exporting table                       ZONE_TBL          6 rows exported
    . . exporting table                            ZOO          2 rows exported
    . . exporting table                    Z_HIERARCHY          3 rows exported
    . . exporting table                         Z_TEST          3 rows exported
    . . exporting table                        Z_TEST4          0 rows exportedIf it's not exporting 0-row tables for you, find out why, and fix that problem. Post your exp control file.
    Someone told me to insert atleast 1 row in the empty tables, then they will be exported.And then, after importing them, TRUNCATE those tables? That's a lot of work.
    That's why I m searching of the Empty Tables.
    Am I going right way ?I don't think so.
    Find and fix the problem with exp.
    If you can't get exp to work, then look into data pump.

Maybe you are looking for

  • Field Bus Area is a required field for G/L 010 191120

    Dear Guru My user going to creta a grn that time he faced some error which is mentioned below " Field Bus. Area is required field for G/L Account xyz yyyyyyy I dont know what is happend please

  • 100% cpu drain few minutes after boot

    I have strange problem with CPU drain. For most of the time 4 cpu (of 8 in total) cores run at 100% after few minutes when system boots (by conky). My desktop laptop is quite powerful but because all of this cpu load it lags even if I play some music

  • SortcompareFunction is not working properly for more than 1 column in advanced datagrid

    Hi Guys, I am using an advanced datagrid with groupingCollection. I have more than 1 grouped column. How ever I am using 2 sort compare function to sort date and time. The problem is when I am trying to sort date its workinf properly then when I jump

  • HOW TO IMPORT PRICE LIST?

    Dear friends. i am facing problem in importing price list,can u plz help me. 1)i have made price list for certen items , that is ok with factor 1 2)now i wants to update this price list through DTW 3)but as per SAP templete i am anable to update it.

  • Report in CRM

    Hello gurus. I try in CRM 2007 to execute a report that obtain data from a bw query. But when I execute the report, an error occurs: "error loading of template ZQUERY_NAMEHTTP" What type of error is it? It is a BW or CRM problem? Thanks in advance. A