azurelunatic: Vivid pink Alaskan wild rose. (Default)
Azure Jane Lunatic (Azz) 🌺 ([personal profile] azurelunatic) wrote2003-04-23 01:20 pm

GHA.

SQL. I can do *calculated* columns just fine, but I'm not sure how to handle this one that says to have it say "High-priced" in a column if the price is above 16000. GHA.

Help?

[identity profile] boojum.livejournal.com 2003-04-23 06:16 pm (UTC)(link)
It's been a bit and I'm too lazy to find a language reference, but I know there's some equivalent of "choose foo where bar > 16000". There might be a set command, so you could say something like "from foo where foo.bar > 16000 set foo.baz 'High-priced'", appropriately massaged by a mind that actually remembers the proper syntax.

Okay, now I'm motivated enough to go look. Looks like "UPDATE Inventory SET PricyDescriptor = 'High Priced' WHERE Price > 16000". (http://www.w3schools.com/sql/sql_update.asp)

I think there's a way to better compress the table and keep consistency if you're only going to have a few specific strings in PricyDescriptor ("High priced", "bargain", "value priced", whatever). Sort of the equivalent of an enum. I think having another table with the strings linked to unique ID numbers is the proper way to do it.

I really need to get SQL working on my computer so I can set up my own personal Bugzilla. 'Cause yum.

[identity profile] godai.livejournal.com 2003-04-25 10:21 am (UTC)(link)
create view accounts (title_id, advance, pricey descriptor)
as select titles.title_id, advance,
if price > 1600 then "High-priced" else ""
from titles, price



something like that.