Questions tagged [distinct]

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

0
votes
2answers
27 views

Finding Distinct Values across 2 tables is not working

I have 2 tables (I've only shown select fields): Table A: <LOCATION CODE> ACT NSWNS OSUSA Parra Parra Parra ACT ACT Table B (A lookup table): <...
0
votes
0answers
18 views

How to get count of unique values of all variables in dataframe in R [duplicate]

I have data frame in R of 110 variables. I want to get count of distinct categories in each of them. I know there is option to check one at the time: lenght(unique(dataframe$x)), but i want to get ...
0
votes
1answer
53 views

How to return single value when duplicate results in XSLT variable?

Using XSLT 1.0 (Xalan)- From this segment of input XML... <LineComponent> <Adjustment Type="Addition" Category="Premium" SubCategory="D240"> <...
-2
votes
0answers
5 views

Not able to get the distinct jobid per id

I have identifier and I am extracting jobId for each identifier. These jobid's are repeated. I want to take the distinct jobid per identifier. ,DISTINCT(res.jobId) FROM ( SELECT em.created_at ...
0
votes
0answers
17 views

How to efficiently count distinct values in a QStandardModel

I'm trying to efficiently count distinct occurrences in a QStandardItemModel and display the results in a QTreeWidget. In a use case where the data model contains 6,000 rows and I am counting the ...
1
vote
1answer
21 views

Hive SQL Distinct Column Syntax Error when calling multiple columns

After using a WITH clause and series of inner joins, I attempted to call back three columns: Employees, SalesID and a COUNT(DISTINCT) and encountered a Syntax Error. This is for a hadoop environment ...
0
votes
1answer
25 views

trying to get only one row from each group

I have a problem with DISTINCT ON. I have five different groups of people which include names and surnames. My goal is to get only one name per group (the first one). When try to use DISTINCT ON, I ...
-1
votes
2answers
30 views

Counting names that have different IDs in SQL

I wrote a code that is supposed to count me the names that are found multiple times in my column Here is what each column represents: col1 = Ids (float, null) col2 = names (nvarchar(255), null) ...
0
votes
0answers
11 views

I've 3 shards, db are not created yet & Mongodb distinct query throws exception in python on accessing db which haven't created yet

Distinct works when shards are not used but upon using shards and if that db isn't created yet throwing exception. In a sharded cluster, the distinct command may return orphaned documents. db = ...
0
votes
2answers
19 views

Select multiple columns having distinct just in 3 of them

i've got a table that i need to return about 14 column values but only return 1 row for the duplicates on some of the columns. The second problem is that between the duplicates i need to keep the ...
0
votes
0answers
12 views

MySQL Similar to select distinct but returning duplicates for each subquery [duplicate]

I need to select each distinct current_stage for each current_well from a table named ticket. My table is: id current_well current_stage ---|------------|--------------- 1 | 5H | 1 ...
-1
votes
1answer
40 views

VBA Finding Unique Distinct Values based on Multiple Dynamic Criteria

It's not too easy to explain this but basically I have a data set that pulls through information to the dashboard. I am looking to find the unique distinct amount of managers matched to 5 ...
2
votes
2answers
77 views

Selecting distinct values from a join of two large tables

I have an animals table with about 3 million records. The table has, among a few other columns, an id, name, and owner_id column. I have an animal_breeds table with about 2.5 million records. The ...
0
votes
0answers
44 views

How to get distinct count within pivot table(Excel for Mac) having filters?

Excel for Mac doesn't support Power Pivot and thereby doesn't have distinct count feature. What is the best workaround to get distinct count in such cases? Sample Excel Columns: Period Criteria1 ...
1
vote
1answer
25 views

Select distinct with order by runs OK when copied to db, but fails when run from application

I have a query which runs OK when I copy it from application console, but fails with an error in application: Caused by: org.postgresql.util.PSQLException: ERROR: for SELECT DISTINCT, ORDER BY ...
0
votes
1answer
11 views

Why Laravel joined query modifies order if distinct is used?

I have the following query: $recentTasks = Task::where('assigned_to','=',$user->id)->join('task_comments','task_comments.task_id','=','tasks.id')->orderBy('task_comments.updated_at','DESC')-&...
1
vote
1answer
14 views

How to Merge Rows with Same Name SQL Pivot

I am trying to denormalize some data in SQL Server and have been able to successfully pivot a reference table, but would like to be able to merge like rows. The pivot is executed as follows select ...
-1
votes
2answers
68 views

SQL Insert Additional Field in Distinct Filter

I would like to insert an additional field to be used in conjunction with an existing one when retrieving records from SQL database. Current query: SELECT CONVERT(date, [DateTime]) 'Date of Download'...
-3
votes
1answer
47 views

Possible to do a pivot outside of BigQuery?

Let's say I'm looking to build the following pivot table: // count by age age male female 1-25 18 23 26-100 19 10 To do this, I can do a basic aggregation like ...
0
votes
1answer
41 views

How to get rows for n distinct values of a column

I need to get rows for n distinct invoice numbers. I have SELECT query that gives me results from the table: SELECT A.INVOICE_NUMBER, A.INVOICE_SEQ_NUMBER, B.FILE_NUMBER FROM TABLE1 AS A, TABLE2 AS ...
0
votes
4answers
43 views

Counting distinct using pandas groupby not working

All I am trying to do is iterate through a DataFrame and count the number of unique values using the pandas group by. I also sorted the data frame to no avail. I've tried 15 different methods and ...
0
votes
1answer
31 views

Convert an ArrayFormula to its equivalent normal Formula in Excel

so I have the following ArrayFormula that counts distinct values in a list that can be filtered.: {=COUNT(1/FREQUENCY(IF((SUBTOTAL(3,OFFSET(C8,ROW(C8:C11508)-ROW(C8),0))=1) *(C8:C11508<>""), ...
2
votes
1answer
33 views

How to optimize subquery

I have a query with multiple subqueries to count how many users involved in a certain transaction depends on status. SELECT * FROM ( SELECT DATE(changes.created_at) AS `date`, SUM(IF(...
0
votes
2answers
43 views

Union n amount of tables in mariadb and find the distinct value based on timestamp

I need to make a search on multiple database tables. Since all tables have the same structure(same columns, they are actually archived data for the same table) I can use UNION ALL to combine them all. ...
0
votes
1answer
24 views

Distinct in Laravel 5 not working properly

I want the distinct names from my database table.The table contains column id and name. I have tried $diff=Crud::distinct('name')->get(); $diff=Crud::distinct()->get(); Both of them not ...
0
votes
2answers
28 views

Too much Data using DISTINCT MAX

I want to see the last activity each individual handset and the user that used that handset. I have a table UserSessions that stores the last activity of a particular user as well as what handset they ...
1
vote
2answers
34 views

select columns' values based on another two values from another column

I have this data set and I need to extract multiple columns values based on on column value. To elaborate on it, I have a rental table, inventory table, customer table, and I want to relate customer ...
1
vote
2answers
20 views

Find the number of unique users who have visited at least two different countries per site

Find the number of unique users who have visited at least two different countries per site. Given timestamp,user,country,site I think the query should look like this, but it doesnt seem right ...
0
votes
2answers
21 views

For each site, find unique number of users whose last visit was to that site

given the table of the following: timestamp, user, site_id For each site, I want to find the number of unique users whose last visit was to that site. I found the number of unique users per site. ...
0
votes
0answers
11 views

Unique user count with distinct function

I have a question about the distinct count. Given a table of timestamp, user_id, country, site_id. I want to find out the number of unique user per site. But with my code, it is not giving me a ...
0
votes
3answers
57 views

How Limit Only 2 Rows To Show For Same Value In MySQL

How to show all data but limit the same name value only 2 rows to show for example, here is my table 'test': id name 1 title-1 2 title-1 3 title-2 4 title-1 5 title-3 6 title-2 7 title-...
0
votes
3answers
34 views

How to select distinct from union result with condition

I want to select distinct vendor with chase if there are two vendor with status register and not register then the choosen one is vendor with status register but if only one vendor then just select it,...
0
votes
2answers
30 views

Select Distinct Records from the table

I would like to write a Query by selecting the dataset from the below image The dataset is from migration_data_temp table I Want the Data to be like the below Image which will populate the actual ...
1
vote
1answer
47 views

How can I filter distinct values on a dropdown menu coming from an excel sheet on PowerApps?

I have a dropdown menu, which accesses an Excel sheet called Clothes and takes in the distinct values from the column Color and then sorts them in ascending order with the following statement: Sort(...
0
votes
4answers
57 views

SQL get unique records and Maintain the Order

I have records like below in my table. I want distinct records and when I do group by it loses the order. I want to maintain the order. I want results like below: This is my query: select route_id,...
0
votes
0answers
66 views

Why I use the distinct and keeps returning me 2 ids with the same value?

I'm using the distinct value but the code keeps returning me 2 IDs with the same value... what can I do? SELECT DISTINCT b.P_USERID as ID, a.P_GROUPNAME as ITEM, a.P_STATUS as STATUS FROM P_GROUPS AS ...
-1
votes
2answers
86 views

SQL Select DISTINCT with WHERE LIKE

I am trying to select distinct BILLCOMPANY from a table with a where BILLCOMPANY like 'value' however it's returning all matches not just distinct. Suggestions? SELECT DISTINCT BillCompany, ...
0
votes
1answer
45 views

Using Spring JPA Select DISTINCT

I am having problems using spring jpa using a Distinct. My goal it's to return the whole object, instead just the field that pass to "Distinct". Example: This is my table: And I want to Distinct ...
2
votes
1answer
51 views

Generating distinct groups based on vector/column pairs in R

SEE UPDATE BELOW: Given a data frame with two columns (x1, x2) representing pairs of objects, I would like to generate groups where all members of each group are paired with all other members in that ...
1
vote
1answer
43 views

Want to remove duplicated rows unless NA value exists in columns

I have a data table with 4 columns: ID, Name, Rate1, Rate2. I want to remove duplicates where ID, Rate1, and Rate 2 are the same, but if they are both NA, I would like to keep both rows. Basically, ...
0
votes
1answer
33 views

How to integrate subquery with other table and grab name column?

I had searching application, finding personal information which had been filtered by some criteria (category, years of experience etc) from itemregistrationpangkat table: itemregistrationpangkatID|...
0
votes
1answer
31 views

MySQL Query Optimization LEFT JOIN and DISTINCT [duplicate]

I have two table in MySQL : system Id_system Name Type ------------------------------ 1 'System1' 'Type1' 2 'System2' 'Type1' 3 'System3' 'Type1' 4 ...
-1
votes
1answer
45 views

Duplicates on joining 2 tables

I have a Select Statement with a lot of data, over 23K, it's joined with over 5 tables one of which is causing the duplicates when I looked at the table I see that the join I am doing have 2 rows ...
1
vote
1answer
42 views

Using Distinct or Case to reduce results in query

The scenario, which is a simple database about tennis, is: Select male players who have atleast two 'e' in their name. (This part fine) Show a list of them who currently have a functie(role) in the ...
1
vote
1answer
37 views

Query to find DISTINCT between array of objects in Cosmos DB [ SQL API ]

I am using Azure Cosmos DB with SQL API and we need to find the DISTINCT values between array of objects in the same document. I have structured the collection in the following ways I have 2 main ...
-1
votes
1answer
41 views

How can I get the first instance of an event per day with multiple columns including a datetime and return those columns plus the full datetime value?

I need to generate a SQL script that will pull out Distinct entries using a number of columns, one of which is a datetime column. I am only interested in the first occurrence of the day per event and ...
0
votes
1answer
53 views

How to get distinct values from data table?

I am trying to return an `array with distinct records. But this piece of code isn’t working. What am I doing wrong? return table.AsEnumerable().Distinct(DataRowComparer.Default).ToArray();
0
votes
1answer
28 views

How can I count double values in SQL Server, comparing multiple columns?

I am setting up a Data Quality Management report for an organisation with multiple administrations. From all the administrations is the data stored in one DataWarehouse. The problem is that different ...
0
votes
2answers
22 views

How to sum a gift amount with out duplicate gifts

I have a table like this-- GiftImpID GiftAmt Category 12345 12.00 Donation 12345 12.00 Donation 56789 10.00 Donation 56789 10.00 Donation 7890 5.00 ...
0
votes
0answers
15 views

Can I use the distinct method like SQL in OData v3?

I would like to query an OData endpoint in order to get a list of distinct values. Is it possible?