Jump to content

SQL Newbie question


montell83
 Share

Recommended Posts

Hello,

I'm new to SQL and i'm trying to create a query that skips a row if the value of "Docent" is empty

if(sis_lvak.idBgrp Is Null, sis_pers.naam_vol, sis_pers_2.naam_vol) as Docent,

My full Query is:

SELECT DISTINCT 
  sis_aanm.idBgrp, 
  sis_aanm.STAMNR STAMNR_2, 
  sis_leer.STAMNR, 
  sis_lvak.C_VAK, 
  sis_bvak.OMSCHR OMSCHR_2, 
  sis_lvak.bVrij, sis_lvak.bExtra, 
  sis_bgrp.GROEP as BasisKlas, 
  sis_bgrp.OMSCHR, 
  sis_svak.volgnr volgnr_2,
  if(sis_lvak.idBgrp Is Null, sis_bgrp.groep, sis_bgrp_2.groep) as RoosterGroep, 
  if(sis_lvak.idBgrp Is Null, sis_pers.naam_vol, sis_pers_2.naam_vol) as Docent,
  if(sis_lvak.bGem=1,'Gemeenschappelijk', IF(sis_lvak.bPvak=1,'Profielvak','Vrij vak')) as SoortVak
FROM sis_aanm sis_aanm
  INNER JOIN sis_leer sis_leer ON (sis_leer.STAMNR = sis_aanm.STAMNR)
  LEFT OUTER JOIN sis_lvak sis_lvak ON (sis_lvak.STAMNR = sis_aanm.STAMNR)
  AND (sis_lvak.idStud = sis_aanm.idStud)
  LEFT OUTER JOIN sis_bgrp sis_bgrp ON (sis_bgrp.idBgrp = sis_aanm.idBgrp)
  LEFT OUTER JOIN sis_pgvk sis_pgvk ON (sis_pgvk.idBgrp = sis_bgrp.idBgrp)
  AND (sis_pgvk.C_VAK = sis_lvak.C_VAK)
  LEFT OUTER JOIN sis_pers sis_pers ON (sis_pers.idPers = sis_pgvk.idPers)
  LEFT OUTER JOIN sis_bgrp sis_bgrp_2 ON (sis_bgrp_2.idBgrp = sis_lvak.idBgrp)
  LEFT OUTER JOIN sis_pgvk sis_pgvk_2 ON (sis_pgvk_2.idBgrp = sis_lvak.idBgrp)
  AND (sis_pgvk_2.C_VAK = sis_lvak.C_VAK)
  LEFT OUTER JOIN sis_pers sis_pers_2 ON (sis_pers_2.idPers = sis_pgvk_2.idPers)
  LEFT OUTER JOIN sis_bvak sis_bvak ON (sis_bvak.C_VAK = sis_lvak.C_VAK)
  LEFT OUTER JOIN sis_stud sis_stud ON (sis_stud.idStud = sis_aanm.idStud)
  INNER JOIN sis_svak sis_svak ON (sis_svak.idSvak = sis_lvak.idSvak)
  LEFT JOIN sis_blpe sis_blpe on sis_aanm.lesperiode=sis_blpe.lesperiode
WHERE 
  ( if(sis_pgvk.idPers Is Null, 1, sis_pgvk.actief) = 1 )
  AND ( if(sis_pgvk_2.idPers Is Null, 1, sis_pgvk_2.actief) = '1' )
  AND (sis_blpe.lesperiode = '1819')
  AND NOT (sis_bvak.OMSCHR = 'ADVIES VOOR DE 2e KLAS'
  OR sis_lvak.bVrij = 'True'
  OR sis_bvak.OMSCHR = 'PlusMentor'
  OR sis_bgrp.GROEP = 'gast')
ORDER BY sis_aanm.STAMNR, sis_svak.volgnr

1674303211_SQLvraag.thumb.png.34a8cd49cb6aab2b7a30dc658159a872.png

Hope somebody can help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...