SELECT investor_id ,  avg(share_count) FROM TRANSACTIONS GROUP BY investor_id ORDER BY avg(share_count)
Show the average share count of transactions each each investor, ordered by average share count.
CREATE TABLE `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);
CREATE TABLE `Lots` (
`lot_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`lot_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` )
);
CREATE TABLE `Ref_Transaction_Types` (
`transaction_type_code` VARCHAR(10) PRIMARY KEY,
`transaction_type_description` VARCHAR(80) NOT NULL
);
CREATE TABLE `Transactions` (
`transaction_id` INTEGER PRIMARY KEY,
`investor_id` INTEGER NOT NULL,
`transaction_type_code` VARCHAR(10) NOT NULL,
`date_of_transaction` DATETIME,
`amount_of_transaction` DECIMAL(19,4),
`share_count` VARCHAR(40),
`other_details` VARCHAR(255),
FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` )
);
CREATE TABLE `Sales` (
`sales_transaction_id` INTEGER PRIMARY KEY,
`sales_details` VARCHAR(255),
FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Purchases` (
`purchase_transaction_id` INTEGER NOT NULL,
`purchase_details` VARCHAR(255) NOT NULL,
FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
CREATE TABLE `Transactions_Lots` (
`transaction_id` INTEGER NOT NULL,
`lot_id` INTEGER NOT NULL,
FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ),
FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` )
);
INSERT INTO Investors (`investor_id`, `Investor_details`) VALUES (1, 'z');
INSERT INTO Lots (`lot_id`, `investor_id`, `lot_details`) VALUES (1, 13, 'r');
INSERT INTO Ref_Transaction_Types (`transaction_type_code`, `transaction_type_description`) VALUES ('SALE', 'Sale');
INSERT INTO Transactions (`transaction_id`, `investor_id`, `transaction_type_code`, `date_of_transaction`, `amount_of_transaction`, `share_count`, `other_details`) VALUES (1, 6, 'SALE', '1988-09-16 19:02:51', '302507.6996', '8718572', NULL);
INSERT INTO Sales (`sales_transaction_id`, `sales_details`) VALUES (1, 'x');
INSERT INTO Purchases (`purchase_transaction_id`, `purchase_details`) VALUES (1, 'c');
INSERT INTO Transactions_Lots (`transaction_id`, `lot_id`) VALUES (3, 11);