I have to get a column that a select to be hidden. More specificaly s.spelersnr but I can't figure out how.
I tried the select a column to be used in my ORDER BY but I don't want to let it show in the result.
SELECT DISTINCT naam,voorletters, TO_CHAR(geb_datum,'dd-mm-yyyy') AS
geboortedatum, b.spelersnr
FROM spelers s LEFT OUTER JOIN boetes b
ON (s.spelersnr = b.spelersnr)
WHERE b.bedrag<75 OR b.bedrag IS null
ORDER BY b.spelersnr
I should get a result without the colum b.spelersnr. But I do get that one how do I hide it?
Use GROUP BY
:
SELECT naam, voorletters, TO_CHAR(geb_datum,'dd-mm-yyyy') AS geboortedatum
FROM spelers s LEFT JOIN
boetes b
ON s.spelersnr = b.spelersnr
WHERE b.bedrag < 75 OR b.bedrag IS null
GROUP BY naam, voorletters, geboortedatum, b.spelersnr
ORDER BY b.spelersnr;
I cannot fathom why you would want to do this -- generating duplicate results, when the column causing the duplication is hidden.
I am guessing that you don't want this logic, but instead:
FROM spelers s LEFT JOIN
boetes b
ON s.spelersnr = b.spelersnr AND b.bedrag < 75
This returns all rows from spelers
with matching values from boetes
where b.bedrag < 75
.