Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need a solution where i have a value say 11 which i need to compute to show it divideeed into two columns A and B sucht that result is like 11 5 column A 4 in column B.
plz advise

What I have tried:

Select SMCount%2 Modulo, (CrewCount-SMCount) NewCrewCount,
Case When SMCount%2 = 1 Then ((CrewCount-(SMCount/2))/2) Else ((CrewCount-SMCount)/2)+1 End A,
--Case When SMCount%2 = 0 Then ((CrewCount-(SMCount/2))/2)-1 Else (((CrewCount-SMCount)/2)) End B,
*
From #Meals M
Posted
Updated 9-Dec-19 22:35pm
Comments
Richard MacCutchan 10-Dec-19 4:12am    
5 + 4 does not equal 11.
Sachin Kulkarni B 10-Dec-19 8:38am    
oh ya,sorry its my mistake, it should have been 6 in A and 5 in B which makes total A+B =11

1 solution

The first thing you need to so is work out exactly how you want to divide them: 5 and 4 do not make 11 except in octal and I doubt that is what you want.
Assuming you want to divide an odd number into two "equal sized" crews, I'd do this:
Crew 1 = AvailableCrew / 2
Crew 2 = AvailableCrew - (AvailableCrew / 2)
This puts the larger crew of an odd value in Crew 2, but that can be swapped if you need. It equally sizes even counts.
 
Share this answer
 
Comments
Sachin Kulkarni B 10-Dec-19 8:39am    
Thanks for the answer
OriginalGriff 10-Dec-19 8:53am    
You're welcome!

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