CREATEVIEW NiceList ASSELECT*FROM Children
WHERE behavior ='nice'AND parent.income >40000;
CREATEVIEW NaughtyList ASSELECT*FROM Children
WHERE behavior ='naughty';
CREATEVIEW NiceList ASSELECT*FROM Children
WHERE behavior >2000AND parent.income >40000;
CREATEVIEW NaughtyList ASSELECT*FROM Children
WHERE behavior <=2000;
I would make two separate views.
CREATE VIEW NiceList AS SELECT * FROM Children WHERE behavior = 'nice' AND parent.income > 40000; CREATE VIEW NaughtyList AS SELECT * FROM Children WHERE behavior = 'naughty';The income is a nice touch.
The poor kids can’t even afford coal and fall through the cracks.
Only the nice ones, the naughty poor children get free coal
But not the poor nice ones
The poor nice ones get beaten by the naughty rich ones.
… and by the “nice” rich ones.
Why are we using magic strings for behavior?
It’s an ENUM and other people have to read this fucking codebase too, Brian!
I’ve a DBA who would insist on this being in a dimension table and using a foreign key constraint instead of just a fucking string
I like your DBA!
Users probably don’t.
Feel free to fork my comment.
CREATE VIEW NiceList AS SELECT * FROM Children WHERE behavior > 2000 AND parent.income > 40000; CREATE VIEW NaughtyList AS SELECT * FROM Children WHERE behavior <= 2000;Does Santa accept PRs?