Kalfja
Kalfja

Reputation: 63

SQL- Distinct Count (SQL Developer)

I need to count the number of test steps in each test case.

I would like to get an answer that shows me NUMBER of test steps for each test case (Test_Case_ID).

I would like the column to be called "Number_Of_Steps"

So far I have this, but it not functional

Select Count(
         Distinct
         (STANDARD_HASH(test_case_id, Test_step_nuber))
         + STANDARD_HASH (Reverse(test_case_id), REVERSE(Test_step_nuber))
       )
from   test_step AS "Number_Of_Steps" ;

Upvotes: 1

Views: 184

Answers (2)

MT0
MT0

Reputation: 167962

You need to alias the computed column (not the table) and, if you want it for each test_case_id then, you need to use GROUP BY:

SELECT test_case_id,
       COUNT( DISTINCT test_step_number ) AS Number_of_steps
FROM   test_step
GROUP BY test_case_id;

I have no idea why you are hashing and reversing the columns.

Upvotes: 1

Stu
Stu

Reputation: 32599

select Test_Case_Id, count(*) as Number_Of_Steps
from Test_Step
group by Test_Case_Id

Upvotes: 1

Related Questions