Search Postgresql Archives

Find min year and min value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,

I am trying to find in a table with different variables, countries and years the

	lowest year

and within that year the

	lowest value


The following SELECT works, but I wonder if it is "elegant". Can you recommend any other solution?


	SELECT
			MIN(value) AS minv
	FROM
			public_one_table.data
	WHERE
			year =
			(
				SELECT
						MIN(year) AS min_year
				FROM
						public_one_table.data
				WHERE
						id_variable = 1
			) AND
			id_variable = 1



Thanks for any help!

Stef

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
      message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux