Link to home
Start Free TrialLog in
Avatar of MrTV
MrTVFlag for Thailand

asked on

delete table if exist then create table postgres

I have table yourtablename  how can Put script to delete table if it exist thwn i can create table


 CREATE TABLE yourtablename AS
SELECT sename."Date",
    sename.name,
    sename."Open",
    sename."Low",
    sename."Close",
    COALESCE(lag(sename."Open") OVER (PARTITION BY sename.name ORDER BY sename.name), sename."Open") AS lag_start,
    COALESCE((sename."Open" - lead(sename."Open") OVER (PARTITION BY sename.name ORDER BY sename."Date")), sename."Open") AS chg
   FROM sename
  ORDER BY sename.name, sename."Date" DESC;
                                  

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of earth man2
earth man2
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial