Results 1 to 3 of 3

Thread: Need help with SQL

  1. #1
    Join Date
    Mar 2003
    Location
    CA
    Posts
    10

    Need help with SQL

    I have 2 tables one called customer and one called order. I am attempting to create a 3rd table then insert data into the 3rd table using a select command. Here is what I have so far can you help me it won't work?

    Create Table Balance
    (customer_id number(7), Last char(10),first char(10),total_balance number (2,d);

    Insert into Balance
    select customer.customer_id,customer.last,customer.first, sum (order.price)
    From customer,order
    where customer.customer_id = order.customer_id
    group by customer.customer_id;


    What am I doing wrong here?


  2. #2
    Join Date
    Mar 2003
    Location
    Brisbane, Australia
    Posts
    1
    You could try this,

    Create Table Balance
    (customer_id number(7), Last char(10),first char(10),total_balance number (2,d);

    Insert into Balance

    select

    customer.customer_id
    , customer.last
    , customer.first
    , sum (order.price)

    From customer left join order on order.customer_id = customer.customer_id

    group by customer.customer_id, customer.last, customer.first;

  3. #3
    Join Date
    Mar 2003
    Location
    CA
    Posts
    10

    Thank You

    I will give it a try Thanks

Posting Permissions

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