Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 20th, 2004, 05:25 PM
vazcro vazcro is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Fort Lauderdale, FL
Posts: 1 vazcro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Firebird With SUM() Different Than Same In MySQL

In MySQL, I wrote a SELECT statement that would summarize total number of therapies, presents and absences for each students ( using a GROUP BY to summarize as should be). The statement looks like this:

select numrecord,nombre,fechainformacion,programa,
referidopor,region,distrito,SUM(totalterapias),
SUM(ausente),SUM(suspendidad),fecharef,
fechaadm from infofact WHERE region=1
and (fechainformacion>='2004-03-01'
and fechainformacion<='2004-03-31')
and referidopor='SPECIAL EDUCATION'
GROUP BY numrecord,programa
ORDER BY region,referidopor,programa,distrito,nombre;

This works every time. But, when I tried to do the same thing in Firebird, Firebird complained that I did not have all the fields in the SELECT statement in my GROUP BY phrase. I only want to group the records captured and SUMmarized by numrecord (record number) and programa (program) so that the resulting subset of records has one record each for a specific student and the specific program he/she was in.

Do I have to use some sort of a sub-query to get this to work? And, if so, then when I've tried to set up what I think is a sub-query, Firebird complains about the inner SELECT.

Help.....New to FIREBIRD....

Vince

Reply With Quote
  #2  
Old September 21st, 2004, 02:58 AM
fikret fikret is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Sarajevo, Bosnia
Posts: 111 fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 5 h 17 m 43 sec
Reputation Power: 8
Limitations of GROUP BY:

When using GROUP BY, be aware of the following limitations:

Each column name that appears in a GROUP BY clause must also be specified in the SELECT

clause.

GROUP BY cannot specify a column whose values are derived from a mathematical,

aggregate, or user-defined function.

GROUP BY cannot be used in SELECT statements that:

· Contain an INTO clause (singleton selects).

· Use a subquery with a FROM clause which references a view whose definition contains

a GROUP BY or HAVING clause.

For each SELECT clause in a query, including subqueries, there can only be one GROUP BY

clause.



--
Best regards,
Fikret Hasovic http://fikret.fbtalk.net
TAMP R&D Team

FirebirdSQL Foundation member.
- Join today at http://www.firebirdsql.org/ff/foundation
JEDI VCS contributor
http://jedivcs.sourceforge.net/

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Firebird With SUM() Different Than Same In MySQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway