![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello everybody out there using PostgreSQL, There is a table within my database which contains the dates with a temperature of more than 30°C in 2009 for many different towns. Here's a short excerpt of it: town | date ------------------- London | 2009-07-12 London | 2009-08-04 Berlin | 2009-06-30 Berlin | 2009-07-15 Berlin | 2009-07-29 Paris | 2009-06-25 Paris | 2009-07-05 Paris | 2009-07-06 Paris | 2009-08-14 I want to know the first and the last day with a temperature of more than 30°C in 2009 for each town. What would be the SELECT statement in SQL for that? |
#3
| |||
| |||
|
|
Hello everybody out there using PostgreSQL, There is a table within my database which contains the dates with a temperature of more than 30°C in 2009 for many different towns. Here's a short excerpt of it: town | date ------------------- London | 2009-07-12 London | 2009-08-04 Berlin | 2009-06-30 Berlin | 2009-07-15 Berlin | 2009-07-29 Paris | 2009-06-25 Paris | 2009-07-05 Paris | 2009-07-06 Paris | 2009-08-14 I want to know the first and the last day with a temperature of more than 30°C in 2009 for each town. What would be the SELECT statement in SQL for that? |
#4
| |||
| |||
|
|
Hello everybody out there using PostgreSQL, There is a table within my database which contains the dates with a temperature of more than 30°C in 2009 for many different towns. Here's a short excerpt of it: town | date ------------------- London | 2009-07-12 London | 2009-08-04 Berlin | 2009-06-30 Berlin | 2009-07-15 Berlin | 2009-07-29 Paris | 2009-06-25 Paris | 2009-07-05 Paris | 2009-07-06 Paris | 2009-08-14 I want to know the first and the last day with a temperature of more than 30°C in 2009 for each town. What would be the SELECT statement in SQL for that? |
#5
| |||
| |||
|
|
Il 18/07/2010 9.37, Julia Jacobson ha scritto: Hello everybody out there using PostgreSQL, There is a table within my database which contains the dates with a temperature of more than 30°C in 2009 for many different towns. Here's a short excerpt of it: town | date ------------------- London | 2009-07-12 London | 2009-08-04 Berlin | 2009-06-30 Berlin | 2009-07-15 Berlin | 2009-07-29 Paris | 2009-06-25 Paris | 2009-07-05 Paris | 2009-07-06 Paris | 2009-08-14 I want to know the first and the last day with a temperature of more than 30°C in 2009 for each town. What would be the SELECT statement in SQL for that? Does your table contains _only_ the records with more than 30° _or_ _also_ the records of temperatures <30? The general query, supposing that the table has dates in multiple years and all temperatures: select min(date) as oldest, max(date) as latest, town from temperatures_table where temperature>30 and extract('year', date)='2009' group by town; errata corrige: |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Hello everybody out there using PostgreSQL, There is a table within my database which contains the dates with a temperature of more than 30°C in 2009 for many different towns. Here's a short excerpt of it: town | date ------------------- London | 2009-07-12 London | 2009-08-04 Berlin | 2009-06-30 Berlin | 2009-07-15 Berlin | 2009-07-29 Paris | 2009-06-25 Paris | 2009-07-05 Paris | 2009-07-06 Paris | 2009-08-14 I want to know the first and the last day with a temperature of more than 30°C in 2009 for each town. What would be the SELECT statement in SQL for that? Thanks in advance, Julia |
![]() |
| Thread Tools | |
| Display Modes | |
| |