I have a column with an array of composite type (text, decimal, timestamp)
as data type. I want to create a query to sum the total of the double column of the composite type. Also I want to perform a group by on the date(day-month-year) of the date time.
Can anyone show me an example of explain how this an be done?
Definition of table and type:
create type stage as (
Stage_Name text,
Stage_Distance decimal,
Stage_Start_Time timestamp
);
CREATE TABLE "Event" (
"Id" serial NOT NULL,
"Location" text,
"Date_Range" daterange,
"Surface" text,
"Stage_Information" stage[],
CONSTRAINT "PK_Event" PRIMARY KEY ("Id")
);
Example data
{"(Newtownards,1.5,\"2015-04-03 18:28:00\")"
,"(\"Bulls Brook\",13.4,\"2015-04-04 09:04:00\")"}
Expected results:
Sum(1.5 + 13.4) = 14.9
Group by 2015-04-03, 2015-04-04