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, 2022 in Database by Neha
• 9,060 points
432 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, 2022 in Database by gaurav
• 23,260 points
1,352 views
0 votes
1 answer

CountifS + multiple criteria + distinct count

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

answered Apr 4, 2022 in Database by Edureka
• 13,690 points
3,503 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
3,936 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
26,808 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,370 points
918 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
587 views
0 votes
0 answers

Simple DateTime sql query

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

Aug 12, 2022 in Database by Kithuzzz
• 38,020 points
574 views
0 votes
0 answers

What represents a double in sql server?

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

Aug 13, 2022 in Database by Kithuzzz
• 38,020 points
716 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, 2022 in Database by Kithuzzz
• 38,020 points
597 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, 2022 in Database by Kithuzzz
• 38,020 points
1,934 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