Mysql's Distinct Group by SQL Syntax Usage

xiaoxiao2021-03-06  69

I originally wanted to count the activation of a game to distribute several times and each time I'm divided.

Select Distinct DistributeTime from OpenTest_code

It can only be distributed to the distribution of activation code, that is, the number of users who have to get the number of users for each time.

Select Distinct DistributeTime, Count (*) from OpenTest_code

First, I will be weak, Test is good, and it is ok, but I have passed, but at the same time, the prompt:

Mixing of group columns (limited) (), max (), count () ...) with no group columns is illegal if there is no group by clause

Look, he is aplane that someone wants to check statistics, prompt group by

Oh, it turns out that the group by is a group of a group!

Select distributetime, count (*) from openteest_code group by distributetime)

This is also right ~~ huh

Look

Select Distinct DistributeTime from OpenTest_code

Select DistributeTime from OpenTest_code Group by DistributeTime

The meaning is the same ,,,

Ha ha,

转载请注明原文地址:https://www.9cbs.com/read-87833.html

New Post(0)