简体   繁体   English

如何 select 从表和整个其他表的一列中区分值?

[英]How to select distinct values from one column from on table and entire other table?

 SELECT  (DISTINCT visits.user_id), purchases FROM visits

Trying to do smth like this but it is not working.试图这样做,但它不起作用。

Use aggregation.使用聚合。 Perhaps:也许:

SELECT v.user_id, ANY_VALUE(purchases)
FROM visits v
GROUP BY v.user_id;

Or, if you want the total number of purchases -- assuming purchases is a number:或者,如果您想要购买总数——假设purchases是一个数字:

SELECT v.user_id, SUM(purchases)
FROM visits v
GROUP BY v.user_id;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MySQL:如果另一列在连接表中有两个确定的值,则从一列中选择不同的值 - MySQL: Select distinct values from one column if other column has two determined values in junction table 在表格中如何通过保留另一列的引用来选择一列的不同值? - In a table how to select distinct values of one column by keeping reference of other column? MySQL:如何从表中选择不同的值? - MySQL: How to select distinct values from a table? 如何从一张桌子中选择不同的 - How to select distinct from just one table MySQL从表的多列中选择不同的记录 - MySQL Select Distinct Records from more than one column of table 如何使用 PHP 从一个 MySQL 表列中选择多个值 - How to select multiple values from one MySQL table column with PHP 如何选择与其他列不存在的一列不同? - How to select distinct from one column where not existing in other columns? MySQL查询从一个表中选择不同的值,并从一个单独的表中选择所有值 - MySQL query to select distinct values from one table and all values from a separate table MySQL从一个表的列中选择一些值(不是所有值),并根据所选值在其他表中求和值 - MySQL select some values (not all values) from column of one table and depending on the selected values sum values in other table 从表和唯一列y中选择ID - select id from table and distinct column y
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM