![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
Hello, I've been trying create a little database for some statistic stuff and decided to use PostgreSQL instead of the more familiar MySQL for it. However, it seems I have a typcial newbie problem and don't know what it expects of. Here is the table (sorry for the German columns, wanted to test how well it gets along with German umlauts): CREATE TABLE kurse ( tag date PRIMARY KEY, eröffnung numeric(7, 2) NOT NULL, höchst numeric(7, 2) NOT NULL, niedrigst numeric(7, 2) NOT NULL, schluss numeric(7, 2) NOT NULL, menge integer DEFAULT 0 NOT NULL CONSTRAINT keine_negative_menge CHECK (menge >= 0) ); and here is the request: bjoern@schatten:~$ LANG=C psql -c "SELECT date_trunk('month', tag), avg(schluss) FROM kurse GROUP BY date_trunk('month', tag) ORDER BY date_trunk('month', tag)" DAX FEHLER: Funktion date_trunk(unknown, date) existiert nicht LINE 1: SELECT date_trunk('month', tag), avg(schluss) FROM kurse GRO... ^ HINT: Keine Funktion stimmt mit dem angegebenen Namen und den Argumenttypen überein. Sie müssen möglicherweise ausdrückliche Typumwandlungen hinzufügen. (means as much as the the function doesn't fit to the argument types) However, the documentation says to date_trunk: "source is a value expression of type timestamp or interval. (Values of type date and time are cast automatically, to timestamp or interval respectively.)" So ... why doesn't it cast the date column `tag' to a timestamp automatically as it is said, and what can I do to fix it? I tried to write TIMESTAMP in front of `tag' but that didn't work either. Björn |
#2
| |||
| |||
|
|
Hello, I've been trying create a little database for some statistic stuff and decided to use PostgreSQL instead of the more familiar MySQL for it. However, it seems I have a typcial newbie problem and don't know what it expects of. Here is the table (sorry for the German columns, wanted to test how well it gets along with German umlauts): CREATE TABLE kurse ( tag date PRIMARY KEY, eröffnung numeric(7, 2) NOT NULL, höchst numeric(7, 2) NOT NULL, niedrigst numeric(7, 2) NOT NULL, schluss numeric(7, 2) NOT NULL, menge integer DEFAULT 0 NOT NULL CONSTRAINT keine_negative_menge CHECK (menge >= 0) ); and here is the request: bjoern@schatten:~$ LANG=C psql -c "SELECT date_trunk('month', tag), avg(schluss) FROM kurse GROUP BY date_trunk('month', tag) ORDER BY date_trunk('month', tag)" DAX FEHLER: Funktion date_trunk(unknown, date) existiert nicht LINE 1: SELECT date_trunk('month', tag), avg(schluss) FROM kurse GRO... ^ HINT: Keine Funktion stimmt mit dem angegebenen Namen und den Argumenttypen überein. Sie müssen möglicherweise ausdrückliche Typumwandlungen hinzufügen. (means as much as the the function doesn't fit to the argument types) However, the documentation says to date_trunk: "source is a value expression of type timestamp or interval. (Values of type date and time are cast automatically, to timestamp or interval respectively.)" So ... why doesn't it cast the date column `tag' to a timestamp automatically as it is said, and what can I do to fix it? I tried to write TIMESTAMP in front of `tag' but that didn't work either. Björn |
#3
| |||
| |||
|
|
Hello, I've been trying create a little database for some statistic stuff and decided to use PostgreSQL instead of the more familiar MySQL for it. However, it seems I have a typcial newbie problem and don't know what it expects of. Here is the table (sorry for the German columns, wanted to test how well it gets along with German umlauts): CREATE TABLE kurse ( tag date PRIMARY KEY, eröffnung numeric(7, 2) NOT NULL, höchst numeric(7, 2) NOT NULL, niedrigst numeric(7, 2) NOT NULL, schluss numeric(7, 2) NOT NULL, menge integer DEFAULT 0 NOT NULL CONSTRAINT keine_negative_menge CHECK (menge >= 0) ); and here is the request: bjoern@schatten:~$ LANG=C psql -c "SELECT date_trunk('month', tag), avg(schluss) FROM kurse GROUP BY date_trunk('month', tag) ORDER BY date_trunk('month', tag)" DAX FEHLER: Funktion date_trunk(unknown, date) existiert nicht LINE 1: SELECT date_trunk('month', tag), avg(schluss) FROM kurse GRO... ^ HINT: Keine Funktion stimmt mit dem angegebenen Namen und den Argumenttypen überein. Sie müssen möglicherweise ausdrückliche Typumwandlungen hinzufügen. (means as much as the the function doesn't fit to the argument types) However, the documentation says to date_trunk: "source is a value expression of type timestamp or interval. (Values of type date and time are cast automatically, to timestamp or interval respectively.)" So ... why doesn't it cast the date column `tag' to a timestamp automatically as it is said, and what can I do to fix it? I tried to write TIMESTAMP in front of `tag' but that didn't work either. Björn |
#4
| |||
| |||
|
|
Hello, I've been trying create a little database for some statistic stuff and decided to use PostgreSQL instead of the more familiar MySQL for it. However, it seems I have a typcial newbie problem and don't know what it expects of. Here is the table (sorry for the German columns, wanted to test how well it gets along with German umlauts): CREATE TABLE kurse ( tag date PRIMARY KEY, eröffnung numeric(7, 2) NOT NULL, höchst numeric(7, 2) NOT NULL, niedrigst numeric(7, 2) NOT NULL, schluss numeric(7, 2) NOT NULL, menge integer DEFAULT 0 NOT NULL CONSTRAINT keine_negative_menge CHECK (menge >= 0) ); and here is the request: bjoern@schatten:~$ LANG=C psql -c "SELECT date_trunk('month', tag), avg(schluss) FROM kurse GROUP BY date_trunk('month', tag) ORDER BY date_trunk('month', tag)" DAX FEHLER: Funktion date_trunk(unknown, date) existiert nicht LINE 1: SELECT date_trunk('month', tag), avg(schluss) FROM kurse GRO... ^ HINT: Keine Funktion stimmt mit dem angegebenen Namen und den Argumenttypen überein. Sie müssen möglicherweise ausdrückliche Typumwandlungen hinzufügen. (means as much as the the function doesn't fit to the argument types) However, the documentation says to date_trunk: "source is a value expression of type timestamp or interval. (Values of type date and time are cast automatically, to timestamp or interval respectively.)" So ... why doesn't it cast the date column `tag' to a timestamp automatically as it is said, and what can I do to fix it? I tried to write TIMESTAMP in front of `tag' but that didn't work either. Björn |
![]() |
| Thread Tools | |
| Display Modes | |
| |