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

Get Distinct Value in a List/Cell in PostgreSQL

it happens that I am having this type of data structure and trying to eliminate the duplicated values under Type in Postgres. Initial Table Index Type 1 A, B 2 A, A 3 B, B Expected Table Index Type 1 A, B 2 A 3 …
Randy
  • 63
  • 8
1
vote
2 answers

R Count and CountDistinct elements of a list

I'm facing a little problem: I've used the Tweeter API and I obtained something like: id <- c(1:4) val <- c(100,150,170,200) tex <- c("[#price", "#quant]","[#good]","[#good] [#price]") db <- data.frame(id,val,tex) I would like to count the total…
Pietro
  • 72
  • 4
1
vote
2 answers

Create New Distinct List(of T) from Existing List(of T) Using LINQ

How can I get a new distinct list from an existing list using LINQ? This is what I have so far and it is not distinct but does give me a new list. Dim tmpQryColumn = (From a In _allAudits Select New CheckBoxListItem …
knockando
  • 992
  • 1
  • 18
  • 34
1
vote
2 answers

Need distinct comma delimited product values order by date

I have below table structure create TABLE PRODUCTDeatils ( Product varchar(50), Date Datetime ) I want an output where i get comma separated list with distinct values but order by date. I first split the values by below query SELECT…
1
vote
1 answer

Ejb-QL DISTINCT ON

Is it possible to use PostgreSQL-like DISTINCT ON in EJB-QL query? What i need to do is to fetch from db records that are distinct on 3 of 10 columns.
mgamer
  • 13,580
  • 25
  • 87
  • 145
1
vote
1 answer

Select everything from SQL database except duplicate

I have a database that looks like this: handshakes ----------------------------------- |id | participant1 | participant2 | ----------------------------------- | 1 | Thomas Miller| Max Miller | | 2 | Thomas Miller| Jack Miller | | 3 | Jack Miller …
Kai
  • 323
  • 2
  • 10
1
vote
1 answer

Mysql - Group by month with unique subscriber user. User should not be repeated

I have the following table with all subscriber users. I want unique subscriber user group by month but if user has already subscribed then should not be repeated in the count. ID | USER | CREATED DATE 1 | 1 | 2019-10-16 2 | 2 |…
1
vote
1 answer

Fetch distinct count of all columns in a single MySQL query

I am trying to fetch distinct count of all columns in a single query. Consider the below table. COL1 | COL2 | COL3 A | 5 | C B | 5 | C C | 5 | C C | 5 | C D | 7 | C Expected result DC_COL1 | DC_COL2 | DC_COL3 #DC -…
Rajesh
  • 13
  • 2
1
vote
2 answers

Removing duplicate records in a dataframe based on the values of a list column

I have a dataframe which contains duplicate values in a list column and I want to keep only the first appearence of each unique value. Let's say I have the following tibble: df <- tribble( ~x, ~y, 1, tibble(a = 1:2, b = 2:3), 2, tibble(a =…
dhersz
  • 525
  • 2
  • 8
1
vote
1 answer

Oracle: Blob column throws inconsistent datatypes

I have three oracle environments, and a query that runs successfully in two environments but throws ORA-00932: inconsistent datatypes: expected - got BLOB in the third environment. The query select distinct mytable.ID as ID1_130_, …
Sara Selim
  • 409
  • 5
  • 21
1
vote
2 answers

SQL query with distinct and group by snowflake

What I'm trying to accomplish is to get all the records for a given MPN, however, I only want the latest DeliveryDate from shpm but given the fact that the MAX function needs to be in the group by clause, It does not get the latest record, it…
1
vote
5 answers

Getting single row from JOIN given an additional condition

I'm making a select in which I give a year (hardcoded as 1981 below) and I expect to get one row per qualifying band. The main problem is to get the oldest living member for each band: SELECT b.id_band, COUNT(DISTINCT a.id_album), …
1
vote
2 answers

How can I distinct count values in a column in R

I have something like this: # A tibble: 24,288 x 1 Country/Region Afghanistan Albania Algeria Andorra Angola Antigua and Barbuda Argentina Armenia Australia Australia ... with 24,278 more rows How can I count the…
Leko
  • 125
  • 5
1
vote
1 answer

Laravel 7 leftJoin, Distinct and Sorted by related created_at

I'm developing a listing ads website dedicated to used video games with Laravel 7. I've got a 'GAMES' table and a 'LISTINGS' table as such. GAMES CREATE TABLE `games` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `title` text COLLATE…
OMP
  • 11
  • 4
1
vote
1 answer

Entity Framework - Distinct Facets - Performance Optimization

Suppose we have a complex generated query... IQueryable<...> query = ... //something complex And then I would like to return multiple "facets" and my current implementation is... var facets = new { Countries =…