Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [distinct]

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

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 ...
Dave Johansen's user avatar
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....
Raul's user avatar
  • 3
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 ...
Theresa Mascis's user avatar
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 ...
ginfonic's user avatar
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 ...
swat's user avatar
  • 83
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 ...
Fem's user avatar
  • 1
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 ...
Chernusha's user avatar
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:...
CBM's user avatar
  • 31
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" ...
Q.Ask's user avatar
  • 117
-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. ...
RodrigoPatrizi's user avatar
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 ...
cornacum's user avatar
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 ...
Jack's user avatar
  • 29
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 ...
Павел's user avatar
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> <...
rocknRrr's user avatar
  • 417
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 ...
Andrew Klimov's user avatar

15 30 50 per page
1
2 3 4 5
345