How to query from the result of a changed column of a table in postgresql
1
vote
1
answer
293
views
I am working with Presto on Amazon Athena. I have a string time column in a table and now I want to change that time to date time type and then query data for selected dates.
Is there a direct way to do so? One way I could think of is
1) add a new column
2) insert values into it with converted date
3) Query using the new column
Here I am stuck with the 2nd step with INSERT so need help with that
ALTER TABLE "db"."table"
ADD COLUMN new_date timestamp
-- Need correction in select statement that I don't understand
INSERT INTO "db"."table" (new_date)
(SELECT new_date from_iso8601_date(substr(timestamp,1,10))
Could some one help me with correction and if possible a better way of doing it?
Asked by Atihska
(129 rep)
Sep 20, 2018, 07:34 PM
Last activity: Oct 5, 2020, 09:08 PM
Last activity: Oct 5, 2020, 09:08 PM