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
• 6,260 points
73 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 Edureka
• 8,820 points
36 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
• 9,320 points
46 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
1,830 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
12,170 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,360 points
237 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
193 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3 in Database by Vaani
• 5,040 points
35 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4 in Database by Vaani
• 5,040 points
12 views
0 votes
1 answer

What is a stored procedure?

A stored procedure is a set of ...READ MORE

answered Feb 4 in Database by Neha
• 6,260 points
74 views
0 votes
1 answer

LEFT JOIN vs. LEFT OUTER JOIN in SQL Server

At the top level there are mainly ...READ MORE

answered Feb 4 in Database by Neha
• 6,260 points
77 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP