Having problem with the following sql statement:
This worked:
And gave these results:
CUSTOMER_NBR LAST_NAME FIRST_NAME RENTAL_ID COPY_NUMBER FEE_TYPE FEE_AMOUNT
------------ -------------------- -------------------- ---------- ----------- ---------- ----------
21111 Smith John 111 1 Rental 5
21111 Smith John 111 1 Late 2
21111 Smith John 111 1 Rewind 1
21111 Smith John 112 2 Rental 5
21111 Smith John 113 3 Rental 5
21111 Smith John 113 3 Rewind 1
</PRE>
</PRE>
Code:
select customer.customer_nbr, last_name, first_name, rental.rental_ID, rental.copy_number, line_item.fee_type, fee_table.fee_amount, sum(fee_table.fee_amount) from person, customer, rental, line_item, fee_table where person.person_ID = customer.person_ID and customer.customer_nbr = rental.customer_nbr and rental.rental_ID = line_item.rental_ID and line_item.fee_type = fee_table.fee_type and customer.customer_nbr = 21111 group by rental.copy_number; </PRE>
Code:
select customer.customer_nbr, last_name, first_name, rental.rental_ID, rental.copy_number, line_item.fee_type, fee_table.fee_amount from person, customer, rental, line_item, fee_table where person.person_ID = customer.person_ID and customer.customer_nbr = rental.customer_nbr and rental.rental_ID = line_item.rental_ID and line_item.fee_type = fee_table.fee_type and customer.customer_nbr = 21111;
CUSTOMER_NBR LAST_NAME FIRST_NAME RENTAL_ID COPY_NUMBER FEE_TYPE FEE_AMOUNT
------------ -------------------- -------------------- ---------- ----------- ---------- ----------
21111 Smith John 111 1 Rental 5
21111 Smith John 111 1 Late 2
21111 Smith John 111 1 Rewind 1
21111 Smith John 112 2 Rental 5
21111 Smith John 113 3 Rental 5
21111 Smith John 113 3 Rewind 1
</PRE>
</PRE>
Comment