If you are the copyright holder of the code, then you can provide the sources to different clients using different licenses. These licenses don't even need to be compatible with each other.
The common mode of dual licensing is that you provide two or more licensing options:
- a (L)GPL (or other copyleft) license for open source projects. The copyleft nature of the GPL ensures that it can't be used for closed-source projects (which most commercial ones still are).
- one or more commercial licenses for use in commercial/closed-source projects. You can vary the fee and license restrictions in any way you like (so a separate license for educational institutions is a possibility).
The thing to watch out for in dual-licensed projects is that you don't blindly accept contributions on your open source version.
Unless you get the copyright on contributions assigned to you, you can't move those contributions over from the open version to the commercially licensed versions, because you would be bound by the GPL license under which the contribution is made.
If the copyright has been assigned to you, then you are free to use the code as you see fit.
Using an open source license that allows sub-licensing means that anyone who gets a copy of your code can legally use it in a closed source project as well.
There are no open-source licenses that prohibit commercial use of the code, as that goes against the ideas behind open source code.