SQLite is the CASE statement expensive?
Posted
by galford13x
on Stack Overflow
See other posts from Stack Overflow
or by galford13x
Published on 2010-04-01T21:27:32Z
Indexed on
2010/04/01
21:33 UTC
Read the original article
Hit count: 428
I'm wondering if using a CASE statement in SQLite (or other SQL engines) to replace data is not advised. For example lets say I have a query.
SELECT Users,
CASE WHEN Active = 0 THEN 'Inactive'
WHEN Active = 1 THEN 'Active'
WHEN Active = 2 THEN 'Processing'
ELSE 'ERROR' AS Active
FROM UsersTable;
When is it better to create a reference table and perform a JOIN. In this case I would create a Table 'ActiveStatesTable' with ActiveID, ActiveDescription and perform the JOIN.
© Stack Overflow or respective owner