In: Computer Science
CREATE TABLE alp_orderline
(order_id int not null,
inv_id int not null,
order_price decimal(6,2) not null,
qty smallint not null,
primary key(order_id, inv_id));
INSERT into alp_orderline
VALUES(1, 1, 274.99, 1);
INSERT into alp_orderline
VALUES(1, 6, 32.95, 2);
INSERT into alp_orderline
VALUES(2, 10, 64.95, 1);
INSERT into alp_orderline
VALUES(3, 16, 15.99, 1);
INSERT into alp_orderline
VALUES(3, 18, 15.99, 1);
INSERT into alp_orderline
VALUES(4, 23, 199.95, 1);
INSERT into alp_orderline
VALUES(5, 21, 15.99, 2);
INSERT into alp_orderline
VALUES(5, 7, 32.95, 1);
INSERT into alp_orderline
VALUES(6, 10, 64.95, 1);
INSERT into alp_orderline
VALUES(6, 26, 209.95, 1);
Answer:
formula :
extended price = order_Unit_Price * order_Quantity * ( 1 - order_discount).
In our case we don't have a discount (discount = 0).
According to given table ,
query for extended price = select (order_price * qty * (1 - 0 ) ); = select ( order_price * qty );
final Query:
select Order_id,inv_id, (order_price * qty) as extended_price from alp_orderline;
here 'as' is used to naming column.
Query Output: