Hello wizards,
I'm having a SQL problem that holds me busy now for more than 5 day's,
the problem is , HOW to SHOW the OCCUPATION of PLACES of child-day-care GROUPS per DA Y's of the week MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY plus
GROUP by WEEK NR.
Week nr. 14
Group name | mon | tues | wed | thu | fri |
Donald duck 9 12 10 11 8
Mckey mouse 8 11 9 12 9
ect....
When I'm looking at this problem, to me it's first splitting the PLACES table, in sub-query's like
SELECT group_name, count (m.monday) AS "monday"
FROM places
WHERE m.monday='H' ./* a kind of OCCUPATION 'H' means 'Hole day'
GROUP BY group_name
ORDER BY m.group_name
Places Table
PLACE_ID
GROUP_ID
GROUP_NAME
MONDAY
TUESDAY
...
BEGIN_DATE
END_DATE
....etc
And then JOINING it together like here down under....... but it doesn't work
SELECT group, monday, tuesday FROM
( SELECT m.group_name,
count (m.monday) AS "monday" ,
count(t.tuesday ) AS "tuesday"
FROM places AS m, places AS t
WHERE m.group_name= t.group_name
AND m.monday='H' . . . . . . . . . . . . . . . . . ./* kind of OCCUPATION 'H' Hole day
AND t.tuesday='H'
GROUP BY m.group_name
ORDER BY m.group_name) AS test
Can somebody please help me out of this misery, I'm using 'PostgreSql- 8.01'and Suse LINUX 9.1
I'm having a SQL problem that holds me busy now for more than 5 day's,
the problem is , HOW to SHOW the OCCUPATION of PLACES of child-day-care GROUPS per DA Y's of the week MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY plus
GROUP by WEEK NR.
Week nr. 14
Group name | mon | tues | wed | thu | fri |
Donald duck 9 12 10 11 8
Mckey mouse 8 11 9 12 9
ect....
When I'm looking at this problem, to me it's first splitting the PLACES table, in sub-query's like
SELECT group_name, count (m.monday) AS "monday"
FROM places
WHERE m.monday='H' ./* a kind of OCCUPATION 'H' means 'Hole day'
GROUP BY group_name
ORDER BY m.group_name
Places Table
PLACE_ID
GROUP_ID
GROUP_NAME
MONDAY
TUESDAY
...
BEGIN_DATE
END_DATE
....etc
And then JOINING it together like here down under....... but it doesn't work
SELECT group, monday, tuesday FROM
( SELECT m.group_name,
count (m.monday) AS "monday" ,
count(t.tuesday ) AS "tuesday"
FROM places AS m, places AS t
WHERE m.group_name= t.group_name
AND m.monday='H' . . . . . . . . . . . . . . . . . ./* kind of OCCUPATION 'H' Hole day
AND t.tuesday='H'
GROUP BY m.group_name
ORDER BY m.group_name) AS test
Can somebody please help me out of this misery, I'm using 'PostgreSql- 8.01'and Suse LINUX 9.1