Linked Questions

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 ...
VDWWD's user avatar
  • 35.6k
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 ...
StepUp's user avatar
  • 38.3k
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 ...
BUlle7's user avatar
  • 161
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 ...
orange's user avatar
  • 1
-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, ...
Gabriel's user avatar
  • 35
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 ...
vbulash's user avatar
  • 351
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 ...
Crampo's user avatar
  • 83
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 | | ...
Marcus Ohlsson's user avatar
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 ...
mrityunjay kumar's user avatar
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 ...
ealfons1's user avatar
  • 373
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 ...
o.o's user avatar
  • 3,751
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
Taylern's user avatar
  • 116
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 ...
sGlow's user avatar
  • 445
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 ...
Bagzli's user avatar
  • 6,605
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 ...
Michael Yoo's user avatar

15 30 50 per page