Changes

Jump to: navigation, search

Difference MySQL PostGreSQL

1,137 bytes added, 10:08, 19 June 2014
no edit summary
</pre>
Note the following regarding the above code:
* All the column definitions starting with ''sum(if''... use aggregation functions (in this case sum()).
* Only one column (hazreduc_guid) is present in the GROUP BY clause, but many columns without an aggregation function are specified in the SELECT clause.
 
In '''PostgreSQL''', even after performing all changes described above on this page, this view definition will not work. The reason is that all the non-aggregation columns of the SELECT statement need to be referred to in the GROUP BY clause. An exception can only be made for those that are dependent on another attribute that is specified in the GROUP BY. In this example, since the hazreduc_guid is in the GROUP BY and it is the primary key of the table HAZREDUC (renamed to ''progress'' in the above query), all other columns of that same table (in this case cast(progress.startdate as date), cast(progress.enddate as date) and progress.areasize can be omitted from the GROUP BY clause.
Taking into account all the changes to be made as described on this page, and looking into the GROUP BY clause issue, the following code would be equivalent in '''PostgreSQL''':
my_view_gazetteer.Village;
</pre>
 
Note that the columns cast(progress.startdate as date), cast(progress.enddate as date) and progress.areasize in the GROUP BY are optional.
== References ==__NOEDITSECTION__
1,068
edits

Navigation menu