473,434 Members | 1,498 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

Whats wrong with this SQL Query?

Error message is Msg 130, Level 15, State 1, Line 1
Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

Expand|Select|Wrap|Line Numbers
  1. SELECT     Film.FilmTitle, Person.FirstName
  2. FROM         Person INNER JOIN
  3.                       Role ON Person.PersonID = Role.PersonID INNER JOIN
  4.                       Film ON Role.FilmID = Film.FilmID
  5. WHERE Film.FilmID IN 
  6. (
  7. SELECT FilmID 
  8. FROM 
  9. Award  
  10. JOIN Role  ON Award.RoleID = Role.RoleID)
  11. AND Film.FilmID = Role.FilmID
  12. AND Role.PersonID = Person.PersonID 
  13. AND Role.PersonID IN
  14. (SELECT     Role.PersonID
  15. FROM         Person INNER JOIN
  16.                       Role ON Person.PersonID = Role.PersonID INNER JOIN
  17.                       Award ON Role.RoleID = Award.RoleID
  18. GROUP BY Role.PersonID
  19. HAVING COUNT(*) =
  20. (
  21.  
  22.    SELECT MAX(COUNT(*) )
  23.          FROM     Award INNER JOIN
  24.              Role ON Award.RoleID = Role.RoleID)
  25. )
May 14 '10 #1
1 1064
ck9663
2,878 Expert 2GB
This part is your problem

Expand|Select|Wrap|Line Numbers
  1.  
  2. HAVING COUNT(*) =
  3. (
  4.  
  5.    SELECT MAX(COUNT(*) )
  6.          FROM     Award INNER JOIN
  7.              Role ON Award.RoleID = Role.RoleID)
  8. )
  9.  
  10.  
Happy Coding!!!

~~ CK
May 17 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Chris Geerdink | last post by:
combo with PHP. what is wrong with the Javascript? else { include("mysql.php"); $query1 = mysql_query("INSERT INTO gbook (naam, email, text) VALUES ('".$_POST."', '".$_POST."',...
4
by: asdf | last post by:
Hello! Can someone tell me whats wrong with this piece of code: Option Compare Database Option Explicit Sub retrieve() Dim rst As ADODB.Recordset Dim i As Integer
5
by: Alexandre Martins | last post by:
Provider=Microsoft.Jet.OLEDB.4.0;UserId=Admin;Password=teste;Data Source=C:\Inetpub\wwwroot\inktoner\dados\db_inktoner.mdb;Persist Security Info=True I can't connect in my database ! whats...
1
by: aa | last post by:
When I am reading from local disk (d:), everithing is OK, but then I am reading from map disk I am geting the this error. Whats wrong. Thanks Server Error in '/Extra' Application....
3
by: mahsa | last post by:
Hi do you know whats wrong with this code? <asp:HyperLink id="HLink_Help" runat="server" NavigateUrl='<%# "javascript:window.open('comments.aspx?id=1,width=500,height=600, scrollBars=yes');"...
1
by: '~=_Slawek_=~' | last post by:
$DOW = (jddayofweek(unixtojd(mktime(1, 1, 1, $month, $day, $year)))+6)%7; $DOW= (jddayofweek(juliantojd($month, $day, $year))+6)%7; The results are supposed to be the same, but they are not....
7
by: Mike Barnard | last post by:
It's a simple test... VERY SIMPLE. But... In an external stlyesheet some attributes don't show. With the same styles cut and pasted to the test internally it works as expected. Anyone tell...
13
by: pankajit09 | last post by:
Whats wrong in the following query --> SELECT SUM(bookings),SUM(invoices),SUM(segments),SUM(totalgross),SUM(totalsale),SUM(commission),SUM(tax),SUM(SELECT grossfare FROM salesqww where type="cash...
5
by: islayer | last post by:
can someone tell me what is wrong with the bold code? i am just learning perl. the program should create a perl file with a random name (5 letters, followed by a number), but the name is always just...
1
by: x40 | last post by:
I try to learn python thru solving some interisting problem, found google trasure hunt, write first program ( but cant find whats wrong). # Unzip the archive, then process the resulting files to...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.