I had never done SQL before, and I read about it. The book I'm reading has an exercise to get me started, I'm also looking for a website called W3School, and the book says that I'm trying to do the following:
Bidding , which has the following structure -
- trade_id: primary key
- timestamp: trade timestamp
- security: basic security (bought or sold in trade)
- quantity: basicquantity (positive means bought, negative indicates sold)
- price: the price of 1 security item for this transaction.
Consider the following table
CREATE TABLE tbProduct
([TRADE_ID] varchar(8), [TIMESTAMP] varchar(8), [SECURITY] varchar(8), [QUANTITY] varchar(8), [PRICE] varchar(8))
;
INSERT INTO tbProduct
([TRADE_ID], [TIMESTAMP], [SECURITY], [QUANTITY], [PRICE])
VALUES
('TRADE1', '10:01:05', 'BP', '+100', '20'),
('TRADE2', '10:01:06', 'BP', '+20', '15'),
('TRADE3', '10:10:00', 'BP', '-100', '19'),
('TRADE4', '10:10:01', 'BP', '-100', '19')
;
, , 10 , 10%.
.
, SQL, , . , , .
:
First_Trade Second_Trade PRICE_DIFF
TRADE1 TRADE2 25
fiddle, . - , , .