MySQL distinct count if conditions unique

Here’s one option using a subquery with DISTINCT: SELECT COUNT(*) gender_count, SUM(IF(gender=”male”,1,0)) male_count, SUM(IF(gender=”female”,1,0)) female_count FROM ( SELECT DISTINCT tel, gender FROM example_dataset ) t SQL Fiddle Demo This will also work if you don’t want to use a subquery: SELECT COUNT(DISTINCT tel) gender_count, COUNT(DISTINCT CASE WHEN gender=”male” THEN tel END) male_count, COUNT(DISTINCT CASE WHEN … Read more

Spark: How to translate count(distinct(value)) in Dataframe API’s

What you need is the DataFrame aggregation function countDistinct: import sqlContext.implicits._ import org.apache.spark.sql.functions._ case class Log(page: String, visitor: String) val logs = data.map(p => Log(p._1,p._2)) .toDF() val result = logs.select(“page”,”visitor”) .groupBy(‘page) .agg(‘page, countDistinct(‘visitor)) result.foreach(println)

Using DISTINCT along with GROUP BY in SQL Server

Use DISTINCT to remove duplicate GROUPING SETS from the GROUP BY clause In a completely silly example using GROUPING SETS() in general (or the special grouping sets ROLLUP() or CUBE() in particular), you could use DISTINCT in order to remove the duplicate values produced by the grouping sets again: SELECT DISTINCT actors FROM (VALUES(‘a’), (‘a’), … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)