balance view

0

Please login or register to vote for this query.

(click on this box to dismiss)

Computer Science Educators

Q&A for those involved in the field of teaching Computer Science

CREATE TABLE #account
(
    id                 integer                 NOT NULL PRIMARY KEY,
    name               varchar(64)               NOT NULL,
    address            varchar(42)               NOT NULL,
    symbol             varchar(10)               NOT NULL,
    network            varchar(10)               NOT NULL,
    type               varchar(100)  NOT NULL,
);

CREATE TABLE #balance
(
    id                 integer                NOT NULL PRIMARY KEY,
    account_id         integer REFERENCES #account (id) NOT NULL,
    amount             bigint                   NOT NULL,
    currency_type      varchar(100)  NOT NULL,
    balance_type       varchar(100) NOT NULL,
    network            varchar(10)              NOT NULL,
);

INSERT INTO #account(id,name,address,symbol,network,type) VALUES (1,'test','test','test','test','test');
INSERT INTO #balance(id,account_id,amount,currency_type,balance_type,network) VALUES (1,1,35576,'test','test','test');
/* INSERT INTO #payment(id,month,balance) VALUES ('0009gmail','2016-03-01',800);
* INSERT INTO #payment(id,month,balance) VALUES ('0009gmail','2016-04-01',1400);
* INSERT INTO #payment(id,month,balance) VALUES ('0009gmail','2016-05-01',-500);
* INSERT INTO #payment(id,month,balance) VALUES ('0019gmail','2016-05-01',-500);
*/
-- aggregated view of the sum of all account balances per account id
-- SELECT account_id, sum(amount) from balance GROUP BY account_id;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results