postgres - scraps of notes

Aggregate function

- aggregate queries 
the SELECT City, max (temp_lo) 
the FROM Weather 
the WHERE City the LIKE '% S' 
the GROUP BY City 
the HAVING max (temp_lo) <40; - the HAVING clause always contain aggregate functions, or no meaning

 

Update statement

-- 更新语句
UPDATE weather
    SET temp_hi = temp_hi - 2,  temp_lo = temp_lo - 2
    WHERE date > '1994-11-28';

 

Affairs

-- 事务
BEGIN;
UPDATE accounts SET balance = balance - 100.00
    WHERE name = 'Alice';
SAVEPOINT my_savepoint;
UPDATE accounts SET balance = balance + 100.00
    WHERE name = 'Bob';
-- oops ... forget that and use Wally's account
ROLLBACK TO my_savepoint;
UPDATE accounts SET balance = balance + 100.00
    WHERE name = 'Wally';
COMMIT;

  

233

Guess you like

Origin www.cnblogs.com/lemos/p/11616398.html