English 中文(简体)
• MySQL
原标题:Invalid Group By Function :: MySQL

首先,我通过职位阅读,名字相匹配,我尝试把一些解决办法结合起来,但我似乎可以让这席文工作......。

问题似乎围绕《公约》第8条的职能。

这里就是这样。


SELECT `purchase_orders`.`purchase_order_id`,`purchase_orders`.`sequence_id`,`purchase_orders`.`order_number`,`vendors`.`name`,`purchase_orders`.`date`,COUNT(`purchase_order_items`.`purchase_order_id`) `item_count`,`purchase_orders`.`total_value`,`purchase_orders`.`status`,`users`.`first`
FROM (`purchase_orders`, `vendors`, `purchase_order_items`,`users`) 
WHERE `purchase_orders`.`aid`= c4ca4238a0b923820dcc509a6f75849b AND`purchase_orders`.`vendor_id`=`vendors`.`vid`AND`purchase_orders`.`created_by`=`users`.`uid`AND`purchase_order_items`.`purchase_order_id`=`purchase_orders`.`purchase_order_id` AND `purchase_orders`.`purchase_order_id` LIKE  %122%  
OR `purchase_orders`.`aid`= c4ca4238a0b923820dcc509a6f75849b AND`purchase_orders`.`vendor_id`=`vendors`.`vid`AND`purchase_orders`.`created_by`=`users`.`uid`AND`purchase_order_items`.`purchase_order_id`=`purchase_orders`.`purchase_order_id` AND `purchase_orders`.`sequence_id` LIKE  %122%  
OR `purchase_orders`.`aid`= c4ca4238a0b923820dcc509a6f75849b AND`purchase_orders`.`vendor_id`=`vendors`.`vid`AND`purchase_orders`.`created_by`=`users`.`uid`AND`purchase_order_items`.`purchase_order_id`=`purchase_orders`.`purchase_order_id` AND `purchase_orders`.`order_number` LIKE  %122%  
OR `purchase_orders`.`aid`= c4ca4238a0b923820dcc509a6f75849b AND`purchase_orders`.`vendor_id`=`vendors`.`vid`AND`purchase_orders`.`created_by`=`users`.`uid`AND`purchase_order_items`.`purchase_order_id`=`purchase_orders`.`purchase_order_id` AND `vendors`.`name` LIKE  %122%  
OR `purchase_orders`.`aid`= c4ca4238a0b923820dcc509a6f75849b AND`purchase_orders`.`vendor_id`=`vendors`.`vid`AND`purchase_orders`.`created_by`=`users`.`uid`AND`purchase_order_items`.`purchase_order_id`=`purchase_orders`.`purchase_order_id` AND `purchase_orders`.`date` LIKE  %122%  
OR `purchase_orders`.`aid`= c4ca4238a0b923820dcc509a6f75849b AND`purchase_orders`.`vendor_id`=`vendors`.`vid`AND`purchase_orders`.`created_by`=`users`.`uid`AND`purchase_order_items`.`purchase_order_id`=`purchase_orders`.`purchase_order_id` AND COUNT(`purchase_order_items`.`purchase_order_id`) LIKE  %122% 
OR `purchase_orders`.`aid`= c4ca4238a0b923820dcc509a6f75849b AND`purchase_orders`.`vendor_id`=`vendors`.`vid`AND`purchase_orders`.`created_by`=`users`.`uid`AND`purchase_order_items`.`purchase_order_id`=`purchase_orders`.`purchase_order_id` AND `purchase_orders`.`total_value` LIKE  %122%  
OR `purchase_orders`.`aid`= c4ca4238a0b923820dcc509a6f75849b AND`purchase_orders`.`vendor_id`=`vendors`.`vid`AND`purchase_orders`.`created_by`=`users`.`uid`AND`purchase_order_items`.`purchase_order_id`=`purchase_orders`.`purchase_order_id` AND `purchase_orders`.`status` LIKE  %122%  
OR `purchase_orders`.`aid`= c4ca4238a0b923820dcc509a6f75849b AND`purchase_orders`.`vendor_id`=`vendors`.`vid`AND`purchase_orders`.`created_by`=`users`.`uid`AND`purchase_order_items`.`purchase_order_id`=`purchase_orders`.`purchase_order_id` AND `users`.`first` LIKE  %122%   
GROUP BY `purchase_orders`.`purchase_order_id`
ORDER BY `purchase_orders`.`purchase_order_id` ASC 
LIMIT 0,1
最佳回答

在您使用<代码>COUNT(xxx)时,您需要在《日刊》中加以使用:

e.g.

HAVING COUNT(xxx) > yyyy

而且,一般而言,你希望按不使用总职能的领域分组。 例如:

SELECT person_name
     , SUM(bonuses)
  FROM person x
     , person_bonus y
 WHERE x.person_id = y.person_id

GROUP BY person_name

由于我增加了该选举说明的栏目,我要么需要对其使用另一个总功能(COUNT、SUM等),要么需要由他们来分组。

同样,你正在使用总功能,可以用于《哈维尔顿条款》:

    SELECT person_name
         , SUM(bonuses)
      FROM person x
         , person_bonus y
     WHERE x.person_id = y.person_id
   GROUP BY person_name
     HAVING SUM(bonuses) > 50000  // I wish :)
问题回答

虽然你可能选择了解决你问题的办法,但你提出的问题确实是毫不怀疑的。 前提是一度在表格中确定与特定钥匙的关系,并在哪里采用任何EXTRA过滤器。 你的询问有多次“或”。 下面是你询问的更干净的版本。 通知哪一条款有你所期望的“援助”和单一条款加入表格...... 根据询问,如果你有这么多的内容,122%的低收入人口将返回,则其余条款和条款将重新编号。

SELECT 
       po.purchase_order_id,
       po.sequence_id,
       po.order_number,
       v.name,
       po.date,
       COUNT( poi.purchase_order_id) item_count,
       po.total_value,
       po.status,
       users.first
    FROM 
       purchase_orders po,
       vendors v,
       purchase_order_items poi,
       users
    WHERE 
           po.aid =  c4ca4238a0b923820dcc509a6f75849b 
       AND po.vendor_id = v.vid
       AND po.purchase_order_id = poi.purchase_order_id
       AND po.created_by = users.uid
   GROUP BY 
       po.purchase_order_id
   ORDER BY 
       po.purchase_order_id
   LIMIT 
       0, 1

我没有理解你所期待的东西,但最后是我前面的所有其他《欧洲睦邻友好协定》条款...... 同样,COUNT(poi.purchase_order_id) 我不认为适用122%的当地收入。 或许,我假设的其他“ID”栏以数字为基础。

       AND po.purchase_order_id LIKE  %122%  
       AND po.sequence_id LIKE  %122%  
       AND po.order_number LIKE  %122%  
       AND v.name LIKE  %122%  
       AND po.date LIKE  %122%  
       AND COUNT(poi.purchase_order_id) LIKE  %122% 
       AND po.total_value LIKE  %122%  
       AND po.status LIKE  %122%  
       AND users.first LIKE  %122%   

您看来,每次都适用所有合并条件,但本应是——要求澄清。

where 
     ( all first group of conditions )
  OR ( all next group of conditions )
  OR ( all next, etc )

我希望这有助于澄清问询的结构。

按条款分列的使用集团的规则:

  1. The column that you GROUP BY must also be in your SELECT statement.
  2. Remember to group by the column you want information about and not the one you are applying the aggregate function on.

In you example, you are checking for purchase_order_items.purchase_order_id = purchase_orders.purchase_order_id and also you are applying an aggregate function COUNT(purchase_order_items.purchase_order_id )





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签