Jump to content

Small SQL Query Help


This topic is 2815 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Cannot get to the bottom of this one... This ExecuteSQL query works fine (all escape characters etc removed for clarity)

  SELECT a."Month Name",  SUM(a."Total")  
  FROM "Orders"  a  
  WHERE a."Year" = ?  
  GROUP BY a."Month Name"
I have a Month Number field also...
Month Number = Month (date)
 But adding that into the query then kills it completely (returns "?")
 
  SELECT a."Month Number", a."Month Name",  SUM(a."Total")  
  FROM "Orders"  a  
  WHERE a."Year" = ?  
  GROUP BY a."Month Name"
I have checked, seems to be appropriate data in all the fields.
Any clues? Driving me batty... 
 
 
Link to comment
Share on other sites

Try

SELECT a."Month Name", a."Month Number",  SUM(a."Total")
FROM "Orders"  a
WHERE a
."Year" = ?
GROUP BY a."Month Name" , a."Month Number"

 

FileMaker says "columns must match the column expression" on page 14 of the SQL reference.pdf

 

You are selecting two columns and creating one aggregate.

All selected columns must be in the GROUP BY clause

 

I would also question your use of a "total" field.. Do you really want the sum of a sum?

Link to comment
Share on other sites

This topic is 2815 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.