I've been trying to figure out how I can implement custom sql into views, as views does not seem to have a 'group by' option.
I have managed to get this working quite well if I add the custom sql into the function 'views_views_pre_execute' in the views.module file. The problem appears when I try to add several custom sql for different views.
I read somewhere I could create a module that would contain the custom sql code and load it into the views module, thus applying it for the required views page.
I tried to follow a forum post
You can move your code to a file called mymodulename.module and put the file in a new folder sites/all/modules/mymodulename (need to be same name), then create a file mymodulename.info in the same folder and put the following info:
; $Id$
name = Name you want to show on modules page eg My Module Name
description = Description you want to show on modules page eg Replaces SQL statement for groups_list2 view.
core = 6.x
version = 6.x-1.0Rename your function in mymodulename.module from views_views_pre_execute to mymodulename_views_pre_execute (.module file, .info file, module directory and module function need to have same name so Drupal can find them).
All I see after enabling the module is a screen full of the sql statement from the module. No error messages just the sql code.
I'd be grateful if anyone knows how I can add several custom sql code to individual views pages.
thanks in advance.