| |
Welcome to the dBforums forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact contact support.
If you prefer not to see double-underlined words and corresponding ads, place your cursor here for ContentLink opt out.
|
 |

06-04-04, 20:46
|
|
Registered User
|
|
Join Date: Apr 2004
Location: Arizona
Posts: 33
|
|
|
Using SUM
|
I get this error when I am using a SUM.
"number of page buffers for cache required"
I tryed looking this error up to see what it means with no pages found. If any of you know what this error means it would help me.
|
|

06-04-04, 20:53
|
|
Registered User
|
|
Join Date: Apr 2004
Location: Arizona
Posts: 33
|
|
|
P.s.
Here is my SQL...
Select
EV.Event_Nbr ,
SE.Sub_Ev_Nbr ,
SE.Room_charge ,
SE.Start_Date ,
SE.Start_Time ,
SE.End_Time ,
EV.Event_Name ,
EV.EvType ,
EV.Client_Name ,
SE.Room_Name ,
EV.BillCatDesc ,
Sum(Event_Nbr) As EventNumberTotal
From
Events EV,
Subevent SE
Where
EV.Event_Nbr = SE.Event_Nbr
and
SE.Start_Date >=  tartdate
And
SE.Start_Date <= :Enddate
And
EV.Status_Level = 1
|
|

06-05-04, 04:15
|
|
Registered User
|
|
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
|
|
|
The query is invalid.
Select a, b, sum(c)
from tableA
GROUP BY a, b
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.
|
|

06-07-04, 12:10
|
|
Registered User
|
|
Join Date: Apr 2004
Location: Arizona
Posts: 33
|
|
Thanks
I forgot to post my group by. I still got the same error with the group by that I was using but I noticed that my group by was not in the same order as my select. I changed the order so that they matched and it worked. Now to see if my arithmatics on time ranges work.
Here is my final SQL....
elect
Ev.Event_Nbr ,
SE.Start_Date ,
SE.Room_Name ,
SE.Sub_Ev_Nbr ,
SE.Start_Time ,
SE.End_Time ,
EV.Event_Name ,
EV.EvType ,
EV.Client_Name ,
SE.Room_Name ,
EV.BillCatDesc ,
(SE.END_TIME - SE.START_TIME) As DailyHours,
Sum(SE.END_TIME - SE.START_TIME) As EventHours
From
Events EV
Left Join Subevent SE On
EV.Event_Nbr = SE.Event_Nbr
Where
SE.Start_Date >=  tartdate
And
SE.Start_Date <= :Enddate
And
EV.Status_Level = 1
Group By
Ev.Event_Nbr ,
SE.Start_Date ,
SE.Room_Name ,
SE.Sub_Ev_Nbr ,
SE.Start_Time ,
SE.End_Time ,
EV.Event_Name ,
EV.EvType ,
EV.Client_Name ,
SE.Room_Name ,
EV.BillCatDesc
Order By
SE.START_TIME,
Ev.Event_Nbr,
SE.Room_Name
My task is to get the hours per day and the total hours per event.
|
|

06-07-04, 16:13
|
|
Registered User
|
|
Join Date: Apr 2004
Location: Arizona
Posts: 33
|
|
|
I think this task is imposable.
I had to rewrite the SQL because it was not totaling on the groups. So I did a subselect and Now I am getting a Singleton Select error.
Here is my SQL,
Select
SE.Event_Nbr ,
SE.Start_Date ,
SE.Room_Name ,
SE.Sub_Ev_Nbr ,
SE.Event_Type ,
SE.Start_Time ,
SE.End_Time ,
EV.Event_Name ,
EV.Client_Name ,
(SE.END_TIME - SE.START_TIME) As DailyHours,
select
Sum(SE.END_TIME - SE.START_TIME)
from
SubEvent SSE
where
SSE.Event_Nbr = SE.Event_Nbr
Group By
SSE.END_TIME,
SSE.START_TIME) As EventHours
From
Events EV,
Subevent SE
Where
EV.Event_Nbr = SE.Event_Nbr
And
SE.Start_Time >=  tartdate
And
SE.Start_Time <= :Enddate
And
EV.Status_Level >= 1
Order By
SE.START_TIME,
Ev.Event_Nbr,
SE.Room_Name
|
|

06-07-04, 23:49
|
|
Registered User
|
|
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
|
|
As an alternative,
select *
from
(select ta.id, sum(ta.fieldB)
from tableA ta
group by ta.id) V
INNER JOIN
tableB tb ON
tb.id = V.id
INNER JOIN
etc.
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.
|
|

06-08-04, 04:39
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,554
|
|
r123456 your syntax is lovely, but how does it help?
ace, your problem is that you want to show individual rows as well as the sum of values over those individual rows
your query is getting an error because you have a GROUP BY in the subselect
a subselect in the SELECT list must be a scalar subselect, i.e. return only one value
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|