Linked Questions
24 questions linked to/from Selecting COUNT(*) with DISTINCT
0
votes
3
answers
1k
views
MS SQL count total items, but only once per user [duplicate]
I want the total unique occurences of NAME from the MS SQL database, but only once for every user. Below is a sample of my data.
USERID NAME
------------------------
1 name 1
1 ...
1
vote
1
answer
819
views
How to get distinct values and count its unrepeatable values? SQL [duplicate]
I have a table SoldCars.
Id_Car Id_Color time
8 2 2015-02-11
8 ...
0
votes
1
answer
583
views
SQL Count, and distinct count(*) by grouping two columns [duplicate]
I have a table with 2 fields: where someid2 is unique filed
GID Name Some_ID1 Some_ID_2 (unique)
-- ------- ------- -------
1 A A1 K1
1 A A1 ...
0
votes
1
answer
120
views
SQL- Do I need some kind of Count function? [duplicate]
I need to query a database that has about 10-11 columns, including a column of id's and a column of role codes. Those are the 2 column that i'm interested in.
ID ROLE
1 a
2 a
2 b
2 ...
-2
votes
1
answer
88
views
Count how many id share the same identical multiple value [duplicate]
Despite research i maked to find the answer in Stack on advised article i cannot find a way to make this query.
I want to know how many distinct ids share the same group of value (brand, category, ...
0
votes
0
answers
49
views
How to get count of unique users [duplicate]
Have the following tables:
Projects:
id
name
1
Project 1
2
Project 2
3
Project 3
Assignments:
id
project_id
user_id
1
1
1
2
1
3
3
1
2
4
2
1
5
3
1
6
3
2
Users:
id
name
1
User 1
2
User 2
3
User 3
I'm ...
6
votes
5
answers
9k
views
Counting Values based on distinct values from another Column
I need to calculate how many orderlines there are based on the orderlineNo being distinct. Each OrderNo is different BUT the OrderLineNo is the same for each order.
i.e. 9 lines on a order then order ...
3
votes
2
answers
2k
views
Count distinct and non distinct values
I have an sql table looking like this:
+----+-----------+------------+
| Id | EnquiryId | PropertyId |
+----+-----------+------------+
| 1 | 1 | 20 |
| 2 | 1 | 25 |
| ...
2
votes
2
answers
2k
views
getting distinct count on join of two tables
I have 2 tables where primary key of first table is used as foreign key for second table. In first table primary key is having unique values but in second table as foreign key it is having duplicate ...
4
votes
2
answers
603
views
How do I perform the following multi-layered pivot with TSQL in Access 2010?
I have looked at the following relevant posts:
How to create a PivotTable in Transact/SQL?
SQL Server query - Selecting COUNT(*) with DISTINCT
SQL query to get field value distribution
Desire: The ...
2
votes
4
answers
639
views
Select rows where string does not repeat
I'm not sure how to phrase this, but I have two tables that I use INNER JOIN on to count the number of records I have. This works fine but the problem is that I have some rows in table1 where some of ...
1
vote
5
answers
636
views
SQL Server : SELECT DISTINCT Group By with Count
I have a table as below.
Is it possible that I can make the output as above?
Thanks
0
votes
1
answer
432
views
Using row_number (or alternative) to count by group, and also only distinct per group?
I am trying to count distinct values per account id using row_number()
This is an example of data that I have:
ID | val
_____________
1 | a
1 | a
1 | b
2 | a
3 | c
3 | a
3 | b
4 | d
4 | d
5 ...
0
votes
2
answers
124
views
Select count of total records and also distinct records
I have a table such as this:
PalmId | UserId | CreatedDate
1 | 1 | 2018-03-08 14:18:27.077
1 | 2 | 2018-03-08 14:18:27.077
1 | 3 | 2018-03-08 14:18:27.077
1 | 1 ...
0
votes
1
answer
153
views
SQL Query with Distinct and Count
I want to know how to query a table with both distinct and count feature.
For example:
SELECT ID, Email, ProductName, ProductModel
FROM Products
What can I do to pull data with Distinct feature on ID ...