select dr_drvname, count(sh_wkflag)
from driver join shift on dr_drvnum = sh_drvnum
where sh_wkflag like '%T%'
group by dr_drvnum;
“T” means true for working that shift. How do I use count and draw names from another table?
Driver table contains all the names. Shift table contains the sh_wkflag which has the value of T or F depending on if the shift has been worked or not. I want to be able to get all the values of “T” and count it. Display the number of “T” grouped by the driver number from the driver table, along with the driver name which is in the driver table as well.
The query runs as long as i dont display the driver name, but i need to display the name as well. The Error i get is, dr_drvname is not a group by expression.
Aha! The error tells all. Add
dr_drvnameto theGROUP BYclause. It’s redundant to grouping bydr_drvnum, but that’s OK.