Search Postgresql Archives

Getting the count(*) from two tables and two date ranges in same query

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

 



Hi all,

 

I have three tables like this:

 

table1 with column table1_ID

table2 with columns table1_ID,  date  ..etc

table3 with columns table1_ID, date ..etc

 

I would like to create one query to retrieve the rowcount ( count(*) ) from both table2 and table3

 

WHERE date BETWEEN fromdate1 AND todate1

 

in one column in the ResultSet

 

WHERE date BETWEEN fromdate2 AND todate2

 

in another column in the ResultSet

 

WHERE table1_ID = some_value

 

..

Resulting in 4 columns in the ResultSet like:

 

count(*)_from_table2_between_fromdate1_and_todate1  = X       

count(*)_from_table2_between_fromdate2_and_todate2  = Y

count(*)_from_table3_between_fromdate1_and_todate1 = Z

count(*)_from_table3_between_fromdate2_and_todate2  = V

 

Is this possible?

 

/Best regards, Håkan Jacobsson – System developer in Sweden

 

 

 

 

 

 

 

 

 

 

 

Håkan Jacobsson - System Developer

----------------------------------------------------------------

 

RELEVANT TRAFFIC EUROPE AB, Riddarg 17D, SE-114 57 Sthlm, Sweden

 

Mobile (+46) 736 56 97 58

Direct   (+46) 8 56 24 98 05

Phone to office (+46) 8 678 97 50 || Fax (+46) 8 661 19 22

 


[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