Selecting COUNT with DISTINCT

0 votes

In SQL Server 2005, I have a database called production that keeps track of all the code that has been deployed. There are other columns in the table, including ticket number, program type, program name, and push number.

GOAL: Count all of the DISTINCT programme names by push number and programme type.

I need to get the unique values, which I'm not getting with the following query:

DECLARE @push_number INT;
SET @push_number = [HERE_ADD_NUMBER];

SELECT DISTINCT COUNT(*) AS Count, programme_type AS [Type] 
FROM production 
WHERE push_number=@push_number 
GROUP BY programme_type
Feb 14 in Database by Neha
• 8,940 points
126 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Database

0 votes
1 answer

How to count distinct values in Excel

Use functions to count the number of ...READ MORE

answered Mar 15 in Database by gaurav
• 22,040 points
522 views
0 votes
1 answer

CountifS + multiple criteria + distinct count

Please enter this formula into a blank ...READ MORE

answered Apr 4 in Database by Edureka
• 13,640 points
643 views
0 votes
2 answers

What are the ways to get the count of records in a table

With the help of the SQL count ...READ MORE

answered Aug 20, 2020 in Database by Okugbe
• 280 points
2,466 views
0 votes
2 answers

Write a SQL query to find the names of employees that begin with ‘S’

Select ename From emp Where ename like"s%"; READ MORE

answered Oct 7, 2021 in Database by anonymous
16,108 views
0 votes
1 answer

What is SELECT DISTINCT statement

This statement is used to return only ...READ MORE

answered Nov 21, 2018 in Database by Sahiti
• 6,380 points
303 views
0 votes
1 answer

Check if my system is compatible with the DB2 Server

Before installing DB2 Server, you need to ...READ MORE

answered Mar 20, 2019 in Database by Lindsy
243 views
0 votes
0 answers

Simple DateTime sql query

How do I query the DateTime database ...READ MORE

Aug 12 in Database by Kithuzzz
• 20,660 points
58 views
0 votes
0 answers

What represents a double in sql server?

I have several properties in C# which ...READ MORE

Aug 13 in Database by Kithuzzz
• 20,660 points
77 views
0 votes
0 answers

How to update two tables in one statement in SQL Server 2005?

In one operation, I want to update ...READ MORE

Aug 20 in Database by Kithuzzz
• 20,660 points
79 views
0 votes
0 answers

Convert Month Number to Month Name Function in SQL

I have the months 1, 2, 3, ...READ MORE

Sep 4 in Database by Kithuzzz
• 20,660 points
99 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP