I need to somehow use the CASE syntax (which is beyond me) to affect the database results based on criteria.
I have a bunch of royalties in 0.# form (royalty)
I have a title ID # (title_id) and I need to show the new increase in royalties so that I can use the data.
IF: they have a current royalty of 0.0 - 0.1 = 10% raise
IF: they have 0.11 - 0.15 = 20% raise
IF: royalty >= 0.16 = 20% raise
Any help would be much appreciated.
create table royalites (
title_id char(6),
lorange integer,
hirange integer,
royalty decimal(5,2));
Actually, you don’t need to use the
casestatement:(under transactional control if you need atomicity). You could possibly combine the first two if they have the same multiplier as your question states.
It works by ensuring you do the higher values first and limit what rows get affected in the
whereclause.If you feel you must use a
casestatement:To just change what you’re pulling out of the table (rather than changing the table itself) and compare it with the current: