Trying to add a sum to a CCK field in a views calc table,

The view has the nid and a cck decimal field from content type office_time_entry.

This is the error that comes back:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT(node.nid), MAX('SUM') AS TOTAL_SUM, ROUND(SUM(node_data_field_dur' at line 1 query: SELECT MAX('') AS DISTINCT(node.nid), MAX('SUM') AS TOTAL_SUM, ROUND(SUM(node_data_field_duration_test.field_duration_test_value), 2) AS node_data_field_duration_test_field_duration_test_value FROM node node LEFT JOIN content_type_office_time_entry node_data_field_duration_test ON node.vid = node_data_field_duration_test.vid WHERE (node.type in ('office_time_entry')) AND (node.nid IN (751))

CommentFileSizeAuthor
#7 views_calc_error.png33.01 KBRosamunda

Comments

hugoncalves’s picture

I´d a similar problem. Any ideas?

corey.aufang’s picture

Status: Active » Fixed

This seems to have been solved when I upgraded to CCK v2.2

Daniel A. Beilinson’s picture

Category: support » bug
Priority: Normal » Critical
Status: Fixed » Active

I've got this error with cck v2.2.:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY node.nid ASC, node_data_field_help_med_type.delta ASC' at line 1 query: SELECT node.vid AS _vid, node_data_field_help_med_type.delta as _delta, node.nid AS _nid, node_data_field_help_med_type.field_help_med_type_value AS value FROM content_field_help_med_type node_data_field_help_med_type LEFT JOIN node node ON node.vid = node_data_field_help_med_type.vid WHERE node.vid IN () ORDER BY node.nid ASC, node_data_field_help_med_type.delta ASC in /var/www/apache2/html/sites/all/modules/cck/cck/includes/views/handlers/content_handler_field_multiple.inc on line 157.

Rosamunda’s picture

In my case it doesn´t show all those errors, but it just won´t work. It shows some random number...
I´m using default float numbers (non distances or something). And it just won´t work.

Rosamunda’s picture

Component: Miscellaneous » Code

I´ve updated cck and still doesn´t work.

Rosamunda’s picture

This is the error that appears after the update:
warning: Invalid argument supplied for foreach() in .../sites/all/modules/views_calc/theme.inc on line 160.
And sometimes, randomly, the error won´t appear, but the view won´t work either.

Rosamunda’s picture

StatusFileSize
new33.01 KB

I´ve forgot to attach a png of what I mean with the strange and random behaviour. The view should show the sum of the one column with the prefix $.

karens’s picture

Status: Active » Postponed (maintainer needs more info)

I can't reproduce the error in the -dev version so either I've got it fixed or you have a different situation.

If you still see problems with the latest -dev code, please give me a specific, reproduceable example of exactly how you set things up and what kind of data is in the field you're totaling.

iNade’s picture

Same problem here, exactly as :

"This is the error that appears after the update:
warning: Invalid argument supplied for foreach() in .../sites/all/modules/views_calc/theme.inc on line 160.
And sometimes, randomly, the error won´t appear, but the view won´t work either"

--

I have one computed field and i wanted to do a SUM request.
NB1 : it's bug too when i tried to do COUNT, AVERAGE, or whatever.
NB2 : When i try with another field (not a computed one), the bug is still there.

It seems that de query is not handle: there's no SUM or whatever in it.
I have tested in the dev version too... and the problem is still there.

Rosamunda’s picture

Exactly the same, but if the field is a text one, that happens to have numbers, I can make it work. Not the ideal situation though.

karens’s picture

Try the -dev version, I can't see any problem there. And I can't tell if the people who posted after I said this earlier have tried the -dev version.

If you're having a problem on the very latest -dev version I need specific information about what kind of field you are using and how the field is set up and what kind of data is in it and how your view is set up. These reports don't have enough information for me to respond in any way to this issue.

iNade’s picture

If you're having a problem on the very latest -dev version I need specific information about what kind of field you are using and how the field is set up and what kind of data is in it and how your view is set up. These reports don't have enough information for me to respond in any way to this issue.

What kind of field ? As I said, every kind of field of the content group in views. Computed field, and CCK ones.
How the field is set up ? What can I said... My computed field is a stocked 32 bits in the DB, float one. The others fields... what would I say ? Tell me how can I be more clear, and i'll tell you what you expect (example).

karens’s picture

You still haven't said if you're using the very latest -dev version. I have made a lot of fixes and I need to know if you see a problem in that version. I've now repeated that three times and you haven't answered that question.

If you still have a problem in the latest code I need enough information to set up a situation like the one you are seeing. I am having no problem so there is something specific to your situation. 'Every kind of field' is not even remotely possible or true. You don't have every kind of field, there are hundreds of them. Which is also why I have have more information.

I don't have any more time for this now and I definitely don't have time to set up random scenarios and hope I stumble across something like yours.

But all of that could be a moot point because it's very possible there is no problem in the latest -dev code, which is why I keep asking if you're using it.

iNade’s picture

Ok.

I've tested with the -dev and the others versions.

b0b’s picture

I had and resolved what I think is the same problem.

Within the same view I had the Default view set to a Table style and the Page view overriding the default with a Views Calc Table style. When I switched the Default view to a Views Calc Table and got rid of the override everything worked fine.

iNade’s picture

Unfortunately, no change here...

Thanks anyway for this feedback !

b0b’s picture

I also updated to the newly released Vews at the same time, which may be another variable?

iNade’s picture

I have the latest views release!

karens’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

I'm closing this issue, it's too confusing to do anything with. The original issue reports an unusual DISTINCT in the query, #6 report a foreach error, others say things like 'me too' that don't tell me anything. I can count at least three or four totally unrelated issues.

Don't report anything about the 1.0 version, I've made changes since then. Only report problems you see in the latest (-dev) version, but wait until tomorrow because I'm making fixes today that won't show up in the tarball until tomorrow.

If you have problems in that version I need an export of your view so I can see how it is set up. I also need details about what is in the fields you are computing. If you are doing a sum of a CCK field I need to see an export of the field so I can see exactly how the field is set up. If you're doing a computation on a computed field, I need to see EXACTLY how that field is configured. It also helps to see the query the view is producing (but don't show only the query without any of the other information because I can't tell anything from that).

Please try to keep each issue to the same thing. Don't report different error messages in the same issue because they're probably not related.

Thanks!