5,172
questions
0
votes
0
answers
42
views
UNION DISTINCT query PHP MySQL results blank
The query below works fine in phpMyAdmin and displays the correct results. However, when implemented on a php page, it shows nothing (a blank page). Can someone help me to display these results in the ...
0
votes
0
answers
11
views
CountIF with distinct values
I am trying to make a countif -- time between 5am and 2pm-- then return "afternoon", for that part i got it right but I just realized that I was counting every row and some of them are ...
1
vote
1
answer
40
views
Snowflake to return all records from duplicate values
Experts,
I have the query below, which returns all duplicate values from Object 1 on Table 1 and adds all other relevant records that come with it.
Select A1.Obj1, AM.Obj2, AM.Obj3, AM.Obj4, A1.Count1
...
0
votes
3
answers
681
views
How do I count and display unique column combinations when using a case statement
I want to get a count of unique column combinations and display the count by the concatenated string of the column values. I use a case statement on each column to transform the column values into ...
-1
votes
3
answers
110
views
SQL unique values for one column
I have data composed of three columns. I would like to get distinct values for 2 columns only (ID, value).
Here is my data:
enter image description here
I would like to have this desired result:
enter ...
1
vote
1
answer
67
views
Access Distinct and Sum Query
In order to help me prepare for camping trips, I'm creating a DB where I can pick what recipes I want to make and print a list of ingredients I need to bring. I've got the following query and results:
...
0
votes
0
answers
15
views
Select(distinct()) Function in MySQL [duplicate]
Apologies, this is probably the easiest question you will get all day;
I am used to working in SSMS and have recently started to use MySQL. I am creating a new project and running the same queries I ...
0
votes
0
answers
18
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
53
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
24
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
95
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 ...
0
votes
1
answer
46
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
17
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
51
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
116
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
39
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"
...
0
votes
2
answers
78
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
51
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
114
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
61
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
33
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
38
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 ...
-1
votes
1
answer
48
views
distinct counting open incident tickets at any give point in time
morning all,
struggling to come up with a solution to this one.
basically i need to be able to distinct count the No of tickets (ID) open at any given time by date
i have a created date , an actual ...
0
votes
0
answers
14
views
Problem on django queryset and distinct/order with annotated fields
Can anybody help with this problem on django queryset distinct/order with annotated fields?
THIS WORKS
It returns nicely and called my Serializer after, no problem at all.
def get_queryset(self) -> ...
4
votes
2
answers
86
views
Direct way for 'distinct() groupwise'
I would like to make the same like distinct() but for groups. Here is an example:
data <- data.frame(
group = c(1, 1, 2, 3, 3, 4, 4, 5, 5),
procedure = c("A", "B", "A&...
0
votes
1
answer
44
views
VB.NET Unique String Combinations Problem
I have two classes. 1 houses all of my records and one I want to only house my unique string combinations.
Public Class Records
Public Property ID As String
Public Property TNumber As String
...
3
votes
2
answers
69
views
Can `Seq.truncate` after `Seq.distinct` in F# be beneficial in terms of performance
In the solution of the Pangram exercise:
let totalAlphabetCount = 1 + int ('Z' - 'A')
let isPangram (input: string): bool =
input
|> Seq.filter System.Char.IsAsciiLetter
|> Seq.map ...
0
votes
0
answers
12
views
MDX: COUNT DISTINCT strange aggregation
I have cube with Stores and SKUHierarchy of Company-Brand-SKU.
I have measure Distinct count of SKU over both dim.
If I try:
SELECT
[Measures].[SKUCount] ON COLUMNS,
[Stores].[Store].[Store] ON ...
0
votes
2
answers
79
views
devide values with JSONata
JSONata is honestly driving me crazy. I asked something similar a couple of weeks ago, but I still don't know what I'm doing so here I am again.
What I'm working with:
[[ {
"time": &...
1
vote
2
answers
56
views
Problem with writing SQL query (Group by, Distinct)
I have a table with three columns. The table describes the various advertisements that the company has.
The first column is advertising, which displays the number of advertisements that is shown to ...
0
votes
0
answers
267
views
Sum only distinct rows in Google Looker Studio
I have a table like this on Google Looker Studio Dashboard.
Batch
Students
A
1
A
1
B
2
B
2
B
2
C
2
C
2
I want to show a score card showing 'Total students across all distinct batches', i.e. 1 ...
0
votes
2
answers
80
views
Custom Sort Order Using Distinct & Case Clauses
Hi I'm having difficulty in using the order by case statement when using alongside distinct keyword. Following is the table
Table with Data
Now in order to achieve custom sort order I'm using the ...
-1
votes
1
answer
77
views
Function to identify unique values and input in a function in R
This is what part of my function looks like:
function_test <- function(x) {
fa_dataset <- test_survey %>%
filter(Tenure_Category == x) %>%
dplyr::select(c(Proud:Respect)) %>%
...
0
votes
1
answer
29
views
Case when with distinct value
I need to calculate how many distinct customers have visited in the tp.places per month and i've tried three different solutions with no luck. What am i missing out?
SELECT
DISTINCT tp.place,
...
0
votes
0
answers
46
views
DISTINCT query in Sequelize using belongsToMany relation and including many tables
I have two related models Product and Category which are joined with belongsToMany relation. I'm trying to fetch those products which has some categories using [Op.in] operator but can't get distinct ...
1
vote
1
answer
36
views
SQL query : creating table with distinct values on selected columns
I'm quite new with SQL. I have a query to construct and fill a table that looks like this:
SELECT
A.ID AS Identification,
B.Name AS Family_name,
B.Firstname AS first_name,
B.Address AS ...
-1
votes
1
answer
56
views
Pivot table outcomes are not the same and I cannot understand why
I have created a pivottable to show which donaters donated for this years campaign but also which donaters donated for this campaign last year.
I wanted to have an overview of the number of donaters ...
1
vote
1
answer
31
views
SQL Query Selecting Multiple Columns Using Distinct on One Column Only (different desired outcome)
There is a same title as mine, but the desired result is different, so please excuse my new thread.
In short, I wanted to select two columns from a table, and I wanted to remove duplicates from one ...
0
votes
1
answer
148
views
Excel formula to find duplicates from multiple sheets and list down on a new sheet or master sheet
I have an excel workbook which stores Employee data. It has 3 sheet which has data coming from 3 different sources. All the 3 sheet has the Employee ID column as common which is ideally the first ...
0
votes
0
answers
23
views
Left Join On table value that is not unique
I have two tables.
The first table is meal_order which has order_id and bundle_id. Now, bundle_id might be the same for multiple order_id and represents that those orders were at one point in one ...
-3
votes
1
answer
40
views
Does Distinct() After sorted() gives different result rather use independent stream? [closed]
I have used distenict() after sorted() and same on list stream both gives diff result
List<String> list1 = Arrays.asList("aaaaa", "b", "lll", "kkk", &...
0
votes
1
answer
52
views
List premises & accounts within time period
I need to pull data from our MS SQL Server database regarding Premises (i.e. houses) and the accounts (i.e. people) that have live there (or are still living there) and their service period at that ...
0
votes
1
answer
165
views
How do I use DISTINCT whilst using Next Value For Expression in SQL
I have a query which uses the Next Value For to generate a unique ID and the rest of the columns are your usual Reference, Name and Type etc. The issue I have is that the Next Value For is generating ...
0
votes
1
answer
16
views
count distintc date and employee_id
I have table like this:
date_entry
emp_id
2024-02-01
emp-001
2024-02-01
emp-001
2024-02-01
emp-002
2024-02-01
emp-003
2024-02-02
emp-001
2024-02-02
emp-002
2024-02-02
emp-003
2024-02-03
emp-...
0
votes
1
answer
62
views
strange behavior i am getting from sqlite. Same values in column but SELECT DISTINCT sees different values
I am getting very strange behavior from SQLite.
INSERT into tbltest (category,question) VALUES ('aa','t1'),('aa','t2'),('Ding 1','d1'),('Ding 1','d2');
SELECT DISTINCT category
FROM tbltest;
I get ...
-1
votes
1
answer
55
views
How to select records in SQL based on probability distribution on one column while making sure that another column value is unique
Context
I have the following Tables in Microsoft SQL Server:
MainTable
UserId
EmailType
Column 1
Column 2
..
Column N
EmailDistribution
EmailType
WeightageRequired
EmailType has about 10 distinct ...
0
votes
0
answers
45
views
I need a measure to distinct count value in a month and when I choose total year it distinct count as well the value in the year in power bi
Rig name
month. Year
Ad 32
8.
Ad 32
8.
Ad 20
8
Ad 32
9.
Ad 20
9.
I need my result when I filter month to be rig count 2 rig in month 8 and 2 rig in month 9
When I choose the whole year I ...
0
votes
1
answer
61
views
how to Select distinct from all columns - display the data to the first column where it occurs
I have a table named egsmaster
mysql workbench version : MySQL Workbench was 8.0.27
so i have this columns named number_id, product, french, german, english, italian
this language are the category for ...
1
vote
1
answer
84
views
How to imitate the SELECT COUNT DISTINCT on PromQL in Grafana
I've been hours trying to imitate the SELECT COUNT DISTINCT on PromQL in Grafana but I'm not able to achieve it.
Let me introduce the following scenario (fictitious, to give an example):
Imagine I ...
1
vote
1
answer
273
views
how to get distinct count on 13 billion records in ABINITIO
I have 13 billion records as mfs file in abinito. I need to count distinct imsis that are grouped by date,city,district. I tried the two things coming to my mind but the operation is soo slow. How to ...