Questions tagged [distinct]

The DISTINCT keyword is used to remove duplicate values from a result of a SQL or SPARQL query.

The DISTINCT keyword is used to remove duplicate values from a result of a SQL or SPARQL query.

The SQL 92 Standard defines DISTINCT as:

Two values are said to be not distinct if either: both are the null value, or they compare equal... Otherwise they are distinct. Two rows (or partial rows) are distinct if at least one of their pairs of respective values is distinct. Otherwise they are not distinct.

The SPARQL 1.1 Specification describes DISTINCT as:

The DISTINCT solution modifier eliminates duplicate solutions. Only one solution that binds the same variables to the same RDF terms is returned from the query.

5114 questions
1
vote
2 answers

DAX: Distinct and then aggregate twice

I'm trying to create a Measure in Power BI using DAX that achieves the below. The data set has four columns, Name, Month, Country and Value. I have duplicates so first I need to dedupe across all four columns, then group by Month and sum up the…
DJL
  • 144
  • 1
  • 12
1
vote
1 answer

SQL count distinct with a condition based on a different column

I have a data set containing a list of exams, the qualifications/units they're associated with, and whether the exam was passed or failed. The data looks something like this: candidate | qualification | unit | exam |…
Sam Walpole
  • 1,116
  • 11
  • 26
1
vote
2 answers

Remove duplicates from listbox/combobox in WPF

I've seen answers mentioning something compact like this:here List withDupes = LoadSomeData(); List noDupes = withDupes.Distinct().ToList(); So I tried the following (syntax) List withDupes =…
Marie
  • 39
  • 1
  • 6
1
vote
1 answer

Count duplicate cell values as one if multiple criteria are met

I am trying to get the total count of entries per month based on the status ("Settled") and the distinct code. If the other status of the other entries in that certain code is not yet settled, it shouldn't count. Please see example below and the…
Isabella
  • 455
  • 1
  • 10
  • 23
1
vote
1 answer

add values based on distinct values of another column from table with multiple records

I have a table like and i want to summaries like this So i want to sum packages for distinct items where my table could have multiple records that i can not just exclude cause are different. I can not just select sum(package) from table group…
kyrpav
  • 756
  • 1
  • 13
  • 43
1
vote
2 answers

Running "distinct on" across all unique thresholds in a postgres table

I have a Postgres 11 table called sample_a that looks like this: time | cat | val ------+-----+----- 1 | 1 | 5 1 | 2 | 4 2 | 1 | 6 3 | 1 | 9 4 | 3 | 2 I would like to create a query that for each unique…
Coder
  • 597
  • 7
  • 22
1
vote
2 answers

Count Distinct and Sum at different group levels in single Oracle query

Below is my query. Is there anyway to use different levels of group levels. I need to get product_count column to count distinct of Product_id but not at account_id and acct_type_id level. Currently the product_count column is coming as 1 for each…
Sara
  • 11
  • 1
1
vote
2 answers

Prevent duplicate values using group by and count distinct simultaneously?

I have a simple table with years and customer id and now I want to group by year and count distinct customers for each year. This is straightforward and works fine, my issue is that I don't want customers in year 1 to repeat in year 2, I only want…
1
vote
1 answer

Cannot select distinct values on joins

Need to join different tables but during join to select distinct rows per one column I have the following…
Spiris
  • 69
  • 2
  • 9
1
vote
2 answers

Selecting distinct values in MongoDB while using Studio 3T

I'd like to to select distinct values from my collection. My query right now, looks like this: use mongo; db.getCollection("Students").find( { "Name" : { "$exists" : true }, "Last_Name" : { …
Mason
  • 11
  • 1
  • 2
1
vote
1 answer

Return multiple COUNT fields for distinct values per a unique ID based on two criteria conditions

I'm trying to work with some logging data in MySQL where I want to be able to tell, per individual, counts of the number of distinct successful requests, distinct unsuccessful requests, non-distinct successful requests, and non-distinct unsuccessful…
lupinist
  • 13
  • 2
1
vote
1 answer

how do I only display each one of the data without repeating with a distinct laravel?

I have a query that takes id_user from several transactions. I just want to find the id_user in the user table by taking only 1 of each data. example: in the query there is a user id [1,1,3,4] i just want to take [1,3,4] so the name that comes out…
sindoro
  • 11
  • 1
1
vote
2 answers

DISTINCT AND COUNT(*)=1 not working on SQL

I need to show the ID (which is unique in every case) and the name, which is sometimes different. In my code I only want to show the names IF they are unique. I tried with both distinct and count(*)=1, nothing solves my problem. SELECT DISTINCT id,…
Ithil Maethor
  • 59
  • 1
  • 7
1
vote
2 answers

MySQL distinct and left, right

I have a table with day column like this: 2011-04-28, 2011-04-29 ... day count name surname 2011-04-28 8 titi tutu 2011-04-28 12 tutu toto 2011-04-27 2 tutu toto 2011-03-12 10 tutu toto I can obtain…
scraly
  • 11
  • 1
1
vote
2 answers

List tree view using eloquent

I have this table structure below TABLE VIEW +------+---------------+---------------+---------------+ |id | group_name | sub_group | title | +------+---------------+---------------+---------------+ |1 | Mobile Phone | Apple …
pal3
  • 241
  • 1
  • 2
  • 13
1 2 3
99
100