sql queries with sql server 2016

1

I'm writing to see what's wrong with this query:
Name of the teacher who teaches all subjects first

select 
    nombre
from profesor inner join imparte on (profesor.p# = imparte.p#)
group by nombre
having (curso like "primero")
    
asked by ras212 13.06.2016 в 19:40
source

1 answer

0

The having clause works when you use a grouping. According to the query you posted, you should use a where

SELECT 
    nombre
FROM profesor INNER JOIN imparte ON (profesor.p# = imparte.p#)
WHERE curso LIKE 'primero'
  • Keep in mind the literals, they go with single quote, not double.
  • In this case, the like works as an equal (=), change your query to be curso = 'primero'
  • The field curso must specify which table it comes from, it is to avoid ambiguities.

Review the having clause to get an idea of the use of groupings.

    
answered by 13.06.2016 / 19:47
source