组功能的使用无效 - #1111

时间:2017-07-12 12:06:24

标签: mysql sql

我有两张桌子

表verkoper

enter image description here

表bestellingen

enter image description here

我的查询:

---
- hosts: localhost
  gather_facts: no
  vars:
    git_ssh_public_key: "Your public ssh key"
    git_ssh_key: |
              -----BEGIN RSA PRIVATE KEY-----
              .... actual key here ....
              -----END RSA PRIVATE KEY-----
  tasks:
  - name: Copy SSH public key file
    copy: 
      content: "{{ git_ssh_public_key }}"
      dest: /root/.ssh/id_rsa.pub
      mode: 0644

  - name: Copy SSH private key file
    copy: 
      content: "{{ git_ssh_key }}"
      #src: id_rsa
      dest: /root/.ssh/id_rsa
      mode: 0600

  - name: Get new source from GIT
    git: 
      repo: "git@gitlab.com:user/repo.git"
      dest: "/var/www/"
      depth: 1
      accept_hostkey: yes
      clone: yes

它给了我错误 SELECT v.naam, SUM(COUNT(b.status) * 1.50) FROM verkoper AS v INNER JOIN bestellingen AS b ON b.verkoper = v.id WHERE b.status = 'retour' GROUP BY b.verkoper 有人有想法吗?

1 个答案:

答案 0 :(得分:2)

我认为这可能是你想要的:

SELECT v.naam, COUNT(*)*1.50
FROM verkoper v INNER JOIN
     bestellingen b
     ON b.verkoper = v.id
WHERE b.status = 'retour'
GROUP BY v.naam;

注意:

  • GROUP BY键应与查询中的未聚合列匹配。
  • 您可以使用COUNT(*)COUNT(1)计算所有行数。输入更简单。
  • 没有理由将COUNT()嵌入SUM()