Questions tagged [distinct]
The DISTINCT keyword is used to remove duplicate values from a result of a SQL or SPARQL query.
distinct
5,167
questions
0
votes
0
answers
14
views
COUNT(DISTINCT <col>) without GROUP BY
In Django, Count("col", distinct=True) can be used to perform COUNT(DISTINCT col) but it automatically adds a GROUP BY so is there a way to prevent that from happening so the distinct count ...
0
votes
1
answer
45
views
COUNT(DISTINCT ...) OVER (PARTITION BY ...) in Postgrsql
I have the following query:
SELECT s.first_field,
s.second_field,
t.third_field,
s.fourth_field,
ROUND(
(SUM(mt.volume) * 100.0 /
SUM(mt....
0
votes
0
answers
21
views
Summary per year in SSRS
I am working in SSRS.
I would like to see a summary yearly of meter readings.
To get the year I used this expression:
=Year(Fields!VerbruikStartdatum.Value)
And for the sum of the meter readings I ...
1
vote
1
answer
50
views
Distinct cumulative count in PostgreSQL window function
I've got a table with many columns some of these are:
product_id, territory_id, quarter_num (it's a number of a quarter from 1 to 28 for instance).
There are some other columns but they aren't ...
1
vote
1
answer
42
views
Select SQL statement on same column
I want to select distinct count(id) as activeusers from a table where useractive=1, but at the same time I want to select all the users example distinct Count(id) as totalusers regardless of ...
0
votes
0
answers
14
views
Distinct count from multiple tables and slicers
To create a gap analysis, I want to create a customer-specific table or matrix, showing products for a given customer, and a second one showing all products available in that country.
We have the ...
0
votes
1
answer
25
views
redshift select distinct rows (group by columns) that contain NULL
what is the best way to get distinct records from the table containing 500 mln records? table structure is id1, id2, id3, upload_date. sample data
id1 id2 id3 upload_date
1 ab cd ...
3
votes
0
answers
68
views
Python - Django - MySQL #need to add distinct() after select_related().distinct() in views.py
so this is ads/views.py
there's a ads/models.py, ads/forms, ads/urls.py and other files, but the one that the grader is complaining is this views.py...
3806 characters of HTML retrieved
Test completed:...
1
vote
1
answer
36
views
How to extract distinct values of array field of embedded documents
Quick disclaimer that I am new to MongoDB.
So, I have a collection called 'Films' where documents have the following structure:
_id: ObjectID('6651be669853a31636ac8f5e')
adult: "False"
...
-1
votes
2
answers
73
views
Select the first row of each GROUP BY in SQL Server
I have two tables and 3 joined columns, ORDER_NO, REASON and ROWID. ORDER_NO is not unique, and I am trying to get the most recent Reason for each order by selecting the max ROWID number by order.
...
2
votes
1
answer
48
views
Results from two tables with DISTINCT
I have a query which returns all unique values from a table.
punches table:
SELECT DISTINCT user_id
FROM punches
WHERE organisation_id = '$current_organisation_id';
This will list of user_id's.
I ...
1
vote
2
answers
103
views
Select DISTINCT but return all columns with MAX(field)?
I am trying to create a SELECT statement that selects all (*) the fields from a table that meet the following:
1 row for each DISTINCT( client_id, fileno, ppyear) combination, but only including the ...
1
vote
1
answer
60
views
Select unique second column per each fist column with minimal value of third column
Using postgres, is it possible or how to select from table below distinct value of id and id2? :
id
id2
a
b
a1
b1
1
2
150
200
200
200
2
2
150
200
200
200
3
2
150
200
200
200
1
4
150
200
200
200
...
0
votes
1
answer
32
views
R count distinct character of days ( n_distinct, nlevels(as.factor()) str_count() are not working)
> test
# A tibble: 30 × 2
# Groups: Week [30]
Week Dates
<dbl> <...
0
votes
1
answer
32
views
Oracle bitmap_construct_agg matview with fast refresh
The question is:
Is that possible?
Or, because of bitmap_construct_agg returns BLOB or RAW it is not possible at all?
This is my test case:
create table testmvb(id number, subid number);
create ...