Questions tagged [distinct]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
14 views

How to put result of MYSQL DISTINCT QUERY in a PHP VARIABLE? [duplicate]

i've a problem trying to get multiple values and concatenate them inside a single php string variable. The idea is to use a MYSQL DISTINCT STATEMENT on a single column of the table like this: $sql = &...
Francesco Minniti's user avatar
1 vote
2 answers
23 views

Query Statement: Using DISTINCT but also using MAX condition

I have a table in my db which is minimally represented below. Note that there are entries under PRV that are duplicates. PRV MV AU G-111 500 LR G-112 400 LC G-112 401 LA G-200 650 LI G-115 350 ...
Lyon Möore's user avatar
0 votes
1 answer
16 views

Powershell group array collection by path as one element, then remaining items into array as second element

Long story short, I'm pumping NTFS permissions into accesscontroldsc/ntfsentry (was using cntfs, but it doesn't work with winsrv2019 and has different keys) dynamically from a source server using get-...
Nicholas McQuillen's user avatar
-1 votes
0 answers
21 views

Specification InvalidDataAccessResourceUsageException after migrating from SpringBoot v2 to v3

I have Spring Data Jpa repository and make call to repo .findAll() with Specification which creates in next public Specification<ProjectMortgageRequest> prepareForBankRegistry(Long bankId, ...
Karp's user avatar
  • 1
-1 votes
1 answer
17 views

How to get distinct records from MySQL table with duplicate/varying Boolean value

I have a table with following structure: Name Subject ExamType Passed Bryan Science Theory True Bryan Science Practical False Joe Science Theory True Joe Science Practical True Jill Science ...
Kapil's user avatar
  • 3
1 vote
1 answer
54 views

SQL update table , case when, select distinct

I have 2 tables as below Table 1: r_report8 work_order_no report8a report_item7 EGR220511003493 56 1 Table2 : rjob_header work_order_no report_item7 EGR220511003493 1 I already set a triggers on ...
Ray's user avatar
  • 23
0 votes
1 answer
38 views

SQL group by multiple columns with seperate where statements and left join

I want to select all delivery stops for a driver. If 2 orders have the same delivery_id location it should only be one stop. Similarly if the pickup_id and delivery_id of different orders are the same ...
Junior Nicolle's user avatar
0 votes
4 answers
70 views

Distinct without group by/having/distinct [duplicate]

I am trying to find an appropriate solution to the following problem: I have an activity-tracking database and I want to get the status at a specific date (ex: 11-Sept) Activity Status Date 100 Done ...
userav's user avatar
  • 17
0 votes
1 answer
17 views

Choose which distinct value to take based on another column - PostgresSQL

I have a table of this kind: name tag inter cep inter a inter b milan a milan c juve r juve cep naples h naples p And I need to take only the distinct names, in a way that if the tag = cep ...
Giacomo F's user avatar
0 votes
1 answer
37 views

How can I count the first initial in a specific column when a join makes the numbers go wrong?

I made a query for practice database and came up with something I would like to see from the database. I wrote a query that gave me the first initial of the last name, the average salary, the total ...
DutchArjo's user avatar
  • 333
0 votes
0 answers
29 views

Add Distinct or GroupBy to LINQ query

var listNews = await (from l in _context.Newss join si in _context.AssignSites on l.NewsId equals si.ParentId into sij from subsi in sij.DefaultIfEmpty() ...
Phan Hien Vo's user avatar
0 votes
2 answers
51 views

How to select only those columns which have some changes ( more than one distinct value)

I have a transactional database with more than 100 columns. Now if I have to select all the rows but only those columns which have changed down the table (more than one distinct value for a particular ...
Notacoder22's user avatar
0 votes
1 answer
26 views

SELECT DISTINCT in Redshift when using with CTE giving error

I built a CTE and I am using the 'SELECT DISTINCT' in the subquery. This query fails giving an error. However the query runs successfully when I don't use the distinct command, just SELECT. I am ...
sutsabs's user avatar
  • 431
1 vote
1 answer
44 views

Loading only distinct records into table via IICS

I have a 4 flatfiles which are coming everyday,I'm taking these r flatfiles as list files as indirect file load. My requirement: I have to load these records in 4 flatfiles into the database. But the ...
 Intiyaz's user avatar
0 votes
2 answers
55 views

distinct() not working for dataframe in R

I'm trying to get specific values from a table regarding COVID 19 cases and I want to find the highest number of cases in each month (there are 4 months). I created a new column for months and then ...
Ano's user avatar
  • 9
0 votes
1 answer
24 views

Distinct date count of records in RealmSwift?

I have records with date field: class SomeRealmObject: Object { @Persisted(primaryKey: true) var _id: ObjectId @Persisted var date: Date ... //some other properties } The goal is to ...
Gargo's user avatar
  • 1,134
0 votes
2 answers
54 views

When a duplicate value exists, only get the row that has columns that are not blank

I have a Customer table inside an Access database that looks like this: CustomerNo CustomerName City State 1234 Jill Vale LA CA 5678 Chris Redd DEN CO 9101 Leon Kerr 2345 Ada Wray PHX AZ 2345 ...
hwight's user avatar
  • 29
2 votes
0 answers
41 views

SQL to count distinct values belonging to another column

Best asked with an example. I have a table: id owner activity error 1 A q 1 2 A q 1 3 A w 0 4 A e 0 5 A r 0 6 B t 1 7 B y 1 8 B u 0 9 B i 0 10 C o 1 11 C p 1 12 C s 1 13 C f 0 14 D g 1 ...
Ryk Waters's user avatar
0 votes
1 answer
42 views

How to see the month with the top number for every year in Microsoft Access SQL?

How do I find the month with the most crime in every year and the number only of the crimes in that month of that year using SQL in Microsoft Access? I tried this, hoping it would give me the result I ...
KATIE.E's user avatar
0 votes
0 answers
27 views

MySQL remove duplicates with OR operator

I have 3 tables (a, b, c) where table c is a "tag" table. Table a is like a product table and table b is the normalized table between table a and c. In words: Entries in table a can have ...
user8918437's user avatar
1 vote
2 answers
35 views

Alternative to using multiple criteria in COUNT(DISTINCT()) or "Error: could not identify an equality operator for type record"

Our vendor recently moved to AWS's Redshift which doesn't appear to allow multiple criteria in a COUNT(DISTINCT()) query. I'm trying to count up all visits made by users in a year, but it's possible ...
user22284214's user avatar
0 votes
1 answer
37 views

SELECT COUNT DISTINCT for Child accounts

Trying to get a count of sub accounts tied to the parent account via the Parent Number. AccountName AccountNum ParentNum Alpha 1000 NULL Beta 2000 NULL ...
David Aerne's user avatar
0 votes
0 answers
5 views

Distinct values on main table left join with another table

Scenario, i have a main table with duplicate records created by deviceID, which i'm trying to dedup by selecting distinct record without device id To be join with catalog table to have the associated ...
Dixon Leong's user avatar
0 votes
1 answer
59 views

How to make sql request in Laravel?

I have a working request in phpMyAdmin SELECT DISTINCT id, name, articul FROM products WHERE category_id=40 order by articul; How can I do this request in Laravel with the right format using a query ...
Andrey Yanok's user avatar
0 votes
0 answers
22 views

Distinct or unique count for a dataframe in Python [duplicate]

I found similar answers but not the way I need it. Data data = {'Column1':[1,2,3,4,5,6,7,8,9,10,11,12,13,], 'Column2':['A','A','A','C','B','A','C','C','B','D','D','E','F'], 'Column3':[...
Rav86's user avatar
  • 65
0 votes
0 answers
33 views

Align the same table with full join and union

I have the following database structure consists of 4 table and query in which represented joins that are required there: -- table 1 create TABLE TBL_1 ( ID INT, GOODS_ID INT, CREATE_DATE ...
badCoder's user avatar
  • 111
0 votes
1 answer
44 views

Postgresql - efficient select distinct

I have a query that is taking too much time to run and I am trying to simplify it. I used https://explain.depesz.com/, and apparently my "unique" node is consuming a lot of computation time. ...
cobdmg's user avatar
  • 49
0 votes
0 answers
33 views

Sum of date difference in big query in days

I want to sum date difference in days from PostionEndDate and PostionStartDate. I have a lot of duplication in my table so in order to get rid of duplication first we need to create a unique ID say ...
Gandelf_the_grey's user avatar
1 vote
1 answer
34 views

How to do a "distinct" (unique) query in the Solr 8 web interface?

We use a Solr 8.11.2 server. Also we use the Solr 8 web user interface to query the Solr cores. How can I make a "distinct" (unique) query using this interface? In my example I want to know ...
Klaus's user avatar
  • 416
0 votes
0 answers
18 views

MYSQL with sum distinct and if

I have three tables. I name it here first, second and third table. Relationship first and second table: One to many Relationship second and third table: One to many I need to count based on second ...
wanna's user avatar
  • 69
0 votes
1 answer
47 views

Grouping incidents and where they happened [closed]

How do I write a query to group incidents by year, block, primary_type,location_description, district, and ward. SELECT year, block, primary_type, location,_description, district,ward FROM `...
Tammy's user avatar
  • 1
0 votes
1 answer
94 views

Distinct count in pivot adds 'empty' to pivot

I was happy to find out there is an option for a distinct count in pivottables. I used it, but found out something happened which I cannot explain: When I use the normal count command, I get a nice, ...
DutchArjo's user avatar
  • 333
2 votes
2 answers
78 views

Saving only the last duplicate by group in R

I have an example dataset: example <- data.frame( date = c("6/1/22", "6/2/22", "6/3/22", "6/1/22", "6/2/22", "6/2/22", "...
jo_'s user avatar
  • 661
1 vote
1 answer
32 views

R function that summarize rows (grouped_by) but disregards duplicate strings and NA

very grateful for your help trying to group/collapse rows of all columns (all but the two columns I use to group_by) and would like to exclude duplicated strings in the merge (only keep distinct ...
Sanna's user avatar
  • 11
-1 votes
2 answers
46 views

DIstinct Serial Number with value updates

Hello thanks for accepting my question, i have below data collected from sensors and i need to get only latest changes from all data, i am using sqlite with sqliteStuidio, please help me with the ...
sanjeev kumar's user avatar
0 votes
0 answers
22 views

Mongoose query returning wrong count for distinct values in collection

I am writing a mongodb query to get the count of distinct data in a collection associated with other field. Here is my query metricsJson.totalPatients = await AppointmentSchema.find({ ...
Pavan Akurathi's user avatar
1 vote
1 answer
61 views

Count two columns in the same table and then count both as total

Project project_id project_name 1 Crispy 2 Smile 3 Genie Artist artist_id artist_name 1 Lisa Simpson 2 John Smith 3 Sally Winter Credit credit_id credit_name 1 Producer 2 Vocalist 3 ...
Mitch's user avatar
  • 75
0 votes
0 answers
32 views

My DISTINCT SQL query taking long time to execute in PostgreSQL

I have more than 50 million rows and its taking hours to get this query done: select distinct column_1 from table_1 where "colour" = 'red'; I tried this: WITH RECURSIVE cte AS ( ( ...
user20777609's user avatar
0 votes
1 answer
54 views

How to take multiple inputs in SQL from an excel sheet

I am trying to find a way to take multiple customer names from an excel sheet to be used in WHERE clause so that I can track the order for those customers! eg: Customer_Name | Quantity | Total ...
Himanshu TOMAR's user avatar
0 votes
4 answers
39 views

Oracle JSON_ARRAYAGG doesn't support DISTINCT keyword

SELECT key1, key2, JSON_ARRAYAGG(foo) foo, JSON_ARRAYAGG(bar) bar FROM ( select 1 as key1, 2 as key2, '1.0' as foo, 'A' as bar from dual UNION select 1, 2, '2.0' , 'A' as bar from dual UNION select ...
JShao's user avatar
  • 21
1 vote
3 answers
65 views

How can I group by a column but return rows with null too?

Let's assume following data: id parent_id 1 null 2 null 3 1 4 1 5 1 I'd like to return all records where parent_id is either null or "distinctized": id parent_id 1 null 2 null 3 1 ...
Martin Sojka's user avatar
0 votes
1 answer
81 views

SQL - Count distinct once a condition from the same column is met

I can find plenty of examples for this online, but the specific part of it being in the same column is what seems to be throwing off any solution I can implement. I have a column with ID another with ...
user1211455's user avatar
0 votes
0 answers
14 views

Query to get distinct value from Jason data with in a field MySQL database

Here is solution to the problem: SELECT DISTINCT JSON_UNQUOTE(JSON_EXTRACT(color, '$.label')) AS label from yourtable-- (get distinct value under Jason data with in a field) SELECT DISTINCT ...
AM Shah's user avatar
0 votes
0 answers
16 views

Distinct for only one value in one column MySQL [duplicate]

Policy Stat P1 PASSED P1 FAILED P2 FAILED P3 PASSED P4 PASSED P4 FAILED This is the example of contents in the table. I wanted to see only which policy is failing every time it runs. I've tried ...
Rajendra Gowd's user avatar
0 votes
2 answers
44 views

How to not display some content if the distinct count is greater than 1

select id,name,major,mark from table where id='001' id name major mark 001 peter english 90 001 peter art 85 ---What I want is: ---- (if the major distinct count >1, show the data ...
rorona's user avatar
  • 25
0 votes
1 answer
48 views

Count distinct text contain in columns which have various texts - Mysql

I have a table: Rank Title Genre 1 Guardians of the Galaxy Action,Adventure,Sci-Fi 2 Prometheus Adventure,Mystery,Sci-Fi 3 Split Horror,Thriller 4 Sing Animation,Comedy,Family 5 Suicide Squad ...
vie.luo's user avatar
0 votes
0 answers
23 views

Rolling six month, distinct count, of number of individuals

I am trying to calculate the number of distinct contacts interacted with in the previous six months for each month. I require to do this for particular organisations and overall. In layman's terms an ...
McDonnell-Douglas's user avatar
0 votes
0 answers
32 views

DISTINCT Results of CTE Outer Apply return empty set

Summary: Results of CTE using OUTER APPLY return duplicates due to dirty nature of data and results of RegexFind to split out commingled key=value pairs. When using DISTINCT on that CTE, the result is ...
Joseph Shirk's user avatar
0 votes
1 answer
34 views

Postgresql unique count satisfying two conditions

I am relatively new programmer. I am trying to create a left join with count of unique rows in a specific column. with normal count it is working fine, nut with unique it is failing. count(case when x....
SANAL RAJ's user avatar
1 vote
1 answer
115 views

How to count and save occurrences in a very large Postgres database?

My experience with Postgres is pretty much nil, my computer is from 2010. So not the fastest, but still going strong. I looked at recommended answers, but I don't get them (yet) - and I'd like to ...
Markus Winter's user avatar

1
2 3 4 5
103