5,180 questions
0
votes
3
answers
185
views
Trouble with SQL Server query containing DISTINCT, ORDER BY and FOR XML PATH commands [closed]
Here is an extract of table B_TimeEntryMatter.
ProformaNr
ActivDate
Description
451894
17/12/2025
To the provision of a Certificate of Incumbency by the Secretary;
451894
18/12/2025
To time spent in ...
-1
votes
2
answers
60
views
Rows from a table that are not in in the same table [duplicate]
this shows me all customers (DISTINCT) with unfulfilled orders:
SELECT DISTINCT
customer
FROM
orders
WHERE shipped='yes'
ORDER BY customer ASC
Works fine, now i want another query which only shows ...
1
vote
1
answer
75
views
Deduplicating array vector rows while maintaining original order
I'm using DolphinDB's array vector as a table column, and I need to deduplicate the elements in each row of this column.
I tried using the distinct statement for deduplication, but according to the ...
4
votes
4
answers
129
views
Find list of GROUPIDs that have ZERO AccountIDs on another table
Looking for SQL that returns a list of GROUPIDs (from the ACCOUNT_GROUP) table that have no ACCOUNTS that are found on the ACCOUNT_LIST table.
ACCOUNT_GROUP (table)
GROUPID
ACCOUNT
GROUP1
111111
...
2
votes
3
answers
117
views
Conditional aggregate and distinct
Using StringAgg with the distinct=True argument works under normal circumstances, e.g.:
entities = entities.annotate(roles=StringAgg(
"credits__role__name",
delimiter=", ",
...
1
vote
2
answers
161
views
Return Distinct Concat Count if More Than One Result
I'm trying to get a distinct count of multiple columns grouped by another column, but I want the results to only include counts greater than ONE. So if I have the following:
SELECT *
FROM cast
ORDER ...
-3
votes
1
answer
98
views
SQL count(username) and count(distinct username) returns same result [closed]
If I execute the following query in my SQL Server:
SELECT COUNT([UserName]), COUNT(DISTINCT [UserName])
FROM [UsersTable]
I get the following (and expected) result:
Now if execute this query:
...
0
votes
3
answers
89
views
Get unique values from column of type "array"
I have this table:
| arrs |
|:----|
| {10000,10000,10000,10000} |
| {100,200,300} |
| {400,500,600} |
| {100,200,600} |
How get this result?
| uniques |
|:-------|
| 10000 |
| 100 |
| 200 |
| 300 |
| ...
0
votes
0
answers
43
views
Slow query due to mandatory buffering
Purpose of my query is to get distinct rows, from a 600 000 rows database.
Everything is fine except that, at one time,I have to keep/extract the first rows of groups after sorting. (step 7 to 9)
And ...
0
votes
0
answers
185
views
Why does SELECT DISTINCT col in Snowflake returns a different number of rows than COUNT(DISTINCT col)?
Query 1:
SELECT
DISTINCT COL
FROM
TABLE
WHERE
MONTH = '2024-09-01'
Query 2:
SELECT
COUNT(DISTINCT COL)
FROM
TABLE
WHERE
MONTH = '2024-09-01'
Query 1 returns 27M ...
0
votes
2
answers
90
views
Mutiple Distinct Record Count from TWO tables having different value need to be matched and reported if there is a difference
I want to compare the count of DELIQUENCY_COUNT=0 with the count of CYCLE_DELIQUENCY = A and Count of DELIQUENCY_COUNT=1 with count of CYCLE_DELIQUENCY = B and so on.
If the count is different a ...
0
votes
1
answer
24
views
How to get unique field values based on recent and highest priority documents in Elasticsearch?
I have an Elasticsearch index that stores documents with the following fields:
timestamp (date)
priority (integer)
user_id (string)
I need to find 5 unique user_id values from the most recent and ...
0
votes
1
answer
70
views
Join with distinct PostgreSQL
I have two tables. Both contain the columns order_ (integer), id_ (UUID), and text_ (text). The tobe table has the correct order_ values while the asis table has incorrect order_ values for the same ...
0
votes
2
answers
92
views
I want to find distinct values from a column in an Access (accdb) database table
I want to select all the rows in a database table where the values in FileSize are unique.
I am using .NET, OleDB, and SQL against an Access database:
ID FileName FileSize
------------------------
...
0
votes
1
answer
93
views
Sum values double counted
I need help with a T-SQL query where I'm adding two columns together. The problem is my code does add them together but then double counts. I've searched around for similar queries but haven't found ...