0

I ran below query to fetch count of data which I can see in output but it does not working as I wish

How can I print count of col6 & col7 in output?

Am I clear?

select col1, col2, 
col3, col4, decode(col5,'S','Success','F','Failed'), col6, col7, count(*)
from mytable 
where col1 in (select FIELD1 from temp)
and col8 = 4
group by col1, col2, col3,col4,col5,col6,col7
1
  • Provide sample data and desired results. Counting columns in the group by clause is not very interesting. The value is always 1 (well, unless the value is NULL). Commented Jun 30, 2020 at 11:20

2 Answers 2

1

See if this works

select count(col6), count(col7)
from mytable 
where col1 in (select FIELD1 from temp)
and col8 = 4;
Sign up to request clarification or add additional context in comments.

Comments

0

You need to use the proper aggregate function and remove the col6 and col7 from GROUP BY clause following query:

select col1, col2, col3, col4, decode(col5,'S','Success','F','Failed'), 
      count(col6), count(col7), count(*) -- used count for col6 and col7
from mytable 
where col1 in (select FIELD1 from temp)
and col8 = 4
group by col1, col2, col3,col4,col5 -- removed col6 and col7 from here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.