Click here to Skip to main content
16,007,472 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi i have two tabled in sql

SHIFT:
[ID]
[PatCount]

VISIT:
[ID]
[ShiftID_FK]

i want get all shifts that count(VISIT.ShiftID_FK) < SHIFT.PatCount for every rows
Posted

1 solution

this one works fine :

Select SHIFT.ID,SHIFT.PatCount from SHIFT 

group by SHIFT.ID,SHIFT.PatCount HAVING ( (select COUNT(VISIT.SHIFT_ID) from VISIT) < SHIFT.PatCount )
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900