Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MSQL in 10 mn ~ Lesson 9 Performing Mathematical Calculations - orderitems ~ expanded_price
-- https://www.safaribooksonline.com/library/view/sams-teach-yourself/9780134649160/ch09.html -- Lesson 9 Performing Mathematical Calculations - orderitems sample #1 CREATE TABLE orderitems ( order_num INT NOT NULL , order_item INT NOT NULL , prod_id NCHAR(10) NOT NULL , quantity INT NOT NULL , item_price MONEY NOT NULL ); ALTER TABLE orderitems ADD CONSTRAINT pk_orderitems PRIMARY KEY (order_num, order_item); INSERT INTO orderitems(order_num, order_item, prod_id, quantity, item_price) VALUES (20005, 1, 'ANV01', 10, 5.99) ,(20005, 2, 'ANV02', 3, 9.99) ,(20005, 3, 'TNT2', 5, 10) ,(20005, 4, 'FB', 1, 10) ,(20006, 1, 'JP2000', 1, 55) ,(20007, 1, 'TNT2', 100, 10) ,(20008, 1, 'FC', 50, 2.50) ,(20009, 1, 'FB', 1, 10) ,(20009, 2, 'OL1', 1, 8.99) ,(20009, 3, 'SLING', 1, 4.49) ,(20009, 4, 'ANV03', 1, 14.99); /* Performing Mathematical Calculations Another frequent use for calculated fields is performing mathematical calculations on retrieved data. Let’s take a look at an example. The item_price column contains the per-unit price for each item in an order. To expand the item price (item price multiplied by quantity ordered), you simply do the following: */ SELECT prod_id , quantity , item_price , quantity*item_price AS expanded_price FROM orderitems WHERE 1=1 AND order_num = 20005 ;
run
|
edit
|
history
|
help
0
SQl_QUEST_2_PRESENTATION_IMG_COUNT
Update Temp table to Insert node in XML data using SQL
join ans
MyWall
Alquileres
2021-03-08_LeetCodeSQL
Query through an error in Sql Server 2008 r2
Get amount of users that bought something soon after registration
MC170402209
db6