{"action":"created","issue":{"url":"https://api.github.com/repos/yajra/laravel-datatables/issues/670","repository_url":"https://api.github.com/repos/yajra/laravel-datatables","labels_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/670/labels{/name}","comments_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/670/comments","events_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/670/events","html_url":"https://github.com/yajra/laravel-datatables/issues/670","id":168300009,"number":670,"title":"Need search datatable with colom alias of sum/count","user":{"login":"raunak-cispl","id":20722929,"avatar_url":"https://avatars.githubusercontent.com/u/20722929?v=3","gravatar_id":"","url":"https://api.github.com/users/raunak-cispl","html_url":"https://github.com/raunak-cispl","followers_url":"https://api.github.com/users/raunak-cispl/followers","following_url":"https://api.github.com/users/raunak-cispl/following{/other_user}","gists_url":"https://api.github.com/users/raunak-cispl/gists{/gist_id}","starred_url":"https://api.github.com/users/raunak-cispl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raunak-cispl/subscriptions","organizations_url":"https://api.github.com/users/raunak-cispl/orgs","repos_url":"https://api.github.com/users/raunak-cispl/repos","events_url":"https://api.github.com/users/raunak-cispl/events{/privacy}","received_events_url":"https://api.github.com/users/raunak-cispl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-29T10:52:14Z","updated_at":"2016-07-31T23:40:46Z","closed_at":null,"body":"### Summary of problem or feature request\r\nHow can I make the datatable to search field which has come from aggregate function like, SUM, COUNT, etc..\r\n\r\nI also check this issue https://github.com/yajra/laravel-datatables/issues/219 but it did't help me and can not able to the get desired output\r\n\r\n### Code snippet of problem\r\nData Source (Modal file)\r\n`$data = DB::table('buyers')\r\n\t\t\t->select('buyers.id', 'buyers.username', DB::raw('COUNT(DISTINCT(' . DB::getTablePrefix() . 'accounts.id)) as total_accounts'), DB::raw('SUM(' . DB::getTablePrefix() . 'account_spend_history.amount_spend) as account_spend_total'))\r\n\t\t\t->leftJoin('accounts', 'buyers.id', '=', 'accounts.buyer_id')\r\n\t\t\t->leftJoin('account_spend_history', 'accounts.id', '=', 'account_spend_history.account_id')\r\n\t\t\t->groupBy('accounts.buyer_id');\r\n$datatables = Datatables::of($data);\r\n        return $datatables->make(true);`\r\n\t\t\r\nMy JS file\r\n\r\n```\r\ntable = $('#inbox-table').DataTable({\r\n\tiDisplayLength: 100,\r\n\taLengthMenu: [[100, 200, 300, 500], [100, 200, 300, 500]],\r\n\tprocessing: true,\r\n\tserverSide: true,\r\n\tscrollX: true,\r\n\tajax: SITEURL + 'buyer/list',\r\n\tcolumns: [\r\n\t\t{\r\n\t\t\tdata: 'id',\r\n\t\t\tname: 'buyers.id'\r\n\t\t},\r\n\t\t{data: 'username', name: 'buyers.username'},\r\n\t\t{\r\n\t\t\tdata: 'total_accounts',\r\n\t\t\tname: 'total_accounts'\r\n\t\t},\r\n\t\t{\r\n\t\t\tdata: 'account_spend_total',\r\n\t\t\tname: 'account_spend_total'\r\n\t\t},\r\n\t\t{\r\n\t\t\tdata: 'action',\r\n\t\t\tname: 'action',\r\n\t\t\torderable: false,\r\n\t\t\tsearchable: false\r\n            className: 'text-center'\t\t}\r\n\t],\r\n\torder: [[1, \"desc\"]],\r\n});\r\n```\r\n\r\nShowing SQL Error\r\n**SQLSTATE[42S22]: Column not found: 1054 Unknown column 'total_accounts' in 'where clause'** \r\n\r\nwhen I replace **name: 'total_accounts'** to **name: 'accounts.id'**\r\nit is showing wrong output\r\n\r\n\r\n### System details\r\n\r\n- PHP Version : 5.6.3\r\n- Laravel Version : 5.1.40 \r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/yajra/laravel-datatables/issues/comments/236464062","html_url":"https://github.com/yajra/laravel-datatables/issues/670#issuecomment-236464062","issue_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/670","id":236464062,"user":{"login":"yajra","id":2687997,"avatar_url":"https://avatars.githubusercontent.com/u/2687997?v=3","gravatar_id":"","url":"https://api.github.com/users/yajra","html_url":"https://github.com/yajra","followers_url":"https://api.github.com/users/yajra/followers","following_url":"https://api.github.com/users/yajra/following{/other_user}","gists_url":"https://api.github.com/users/yajra/gists{/gist_id}","starred_url":"https://api.github.com/users/yajra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yajra/subscriptions","organizations_url":"https://api.github.com/users/yajra/orgs","repos_url":"https://api.github.com/users/yajra/repos","events_url":"https://api.github.com/users/yajra/events{/privacy}","received_events_url":"https://api.github.com/users/yajra/received_events","type":"User","site_admin":false},"created_at":"2016-07-31T23:40:46Z","updated_at":"2016-07-31T23:40:46Z","body":"See this demo for ref: \r\nhttps://datatables.yajrabox.com/eloquent/advance-filter\r\nhttps://datatables.yajrabox.com/eloquent/post-column-search\r\n\r\nTry using `filterColumn` api and use having query."}}
{"actor":{"display_login":"yajra"}}