special table output!!!

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

special table output!!!

Post by joecrack »

Hai
i want to build a table output that is ordered like this:
http://rzserv2.fhnon.de/~lg016500/untitled1.bmp
(the <10, <100 etc is just an example - i want it to be seperatet by different dates)
I want to fill out the blanks, but i dont know how i have to do the SELECTs.
It could be done like this:

Code: Select all

SELECT sum(tovalue)  from sam_date_val group by actdeldate BETWEEN DATE '2003-01-01' AND DATE '2005-08-08' AND actdeldate BETWEEN DATE '2005-09-09'AND DATE '2015-08-08'
But i just get one output that i want. I just get one output, but i want to have a new collum with the second date select. Is it possible to make a SELECT for every row???
joe
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post by joecrack »

so now i got a sql command like this:

Code: Select all

SELECT 
   sum(tovalue) 
FROM 
   sam_date_val 
GROUP BY 
   contrdate 
BETWEEN 
   DATE '$year-01-01'
   AND 
   DATE '$year-01-31', contrdate 
BETWEEN 
   DATE '$year-02-01'
   AND 
   DATE '$year-02-30', contrdate 
BETWEEN 
   DATE 
...................
But it makes a new rows for every group .. and i want it all to be in onerow!?!
AND i still have to group t, means if i do it like this, i still have to make at least two more SELECTS!!!
Last edited by joecrack on Thu Nov 24, 2005 7:22 pm, edited 2 times in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I've modified your query to be readable by humans... next time please do the same.
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post by joecrack »

plz somebody ...
just some approach ....
Post Reply