SQL query is not grouping

Asked

Viewed 100 times

0

I’m new in SQL and I’m trying to group the data as query below, however, is not grouping. The correct one was to leave, for example

select
    left(P.ProjDesc,6),
    COUNT(P.ProjID)
from Projetos P
where P.ProjStatus <> 9 
group by p.ProjDesc
  • Be more specific about the goal of the query, which you really want to return ?

  • Well, it was to return in the following way Descricathe Number of Projects Rafael 50 Teles 20 , but it is coming like this Rafael 1 Rafael 1 Rafael 1 Rafael 1 Teles 1 Teles 1 Teles 1 Teles 1

1 answer

2


Renan,

From what I understand, you want to group from the LEFT. Use the query below.

select 
     left(P.ProjDesc,6), 
     COUNT(P.ProjID) 
from 
     Projetos P 
where 
     P.ProjStatus <> 9 
group by 
     left(P.ProjDesc,6)

In this case, you will group by the same column you selected.

Hug,

  • Ah . Show Ball Jean. I forgot this detail. Thank you guys. Hugs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.