Sum columns with null values in oracle

NVL(value, default) is the function you are looking for. select type, craft, sum(NVL(regular, 0) + NVL(overtime, 0) ) as total_hours from hours_t group by type, craft order by type, craft Oracle have 5 NULL-related functions: NVL NVL2 COALESCE NULLIF LNNVL NVL: NVL(expr1, expr2) NVL lets you replace null (returned as a blank) with a string … Read more

ANSI_NULLS and QUOTED_IDENTIFIER killed things. What are they for?

OK, from an application developer’s point of view, here’s what these settings do: QUOTED_IDENTIFIER This setting controls how quotation marks “..” are interpreted by the SQL compiler. When QUOTED_IDENTIFIER is ON then quotes are treated like brackets ([…]) and can be used to quote SQL object names like table names, column names, etc. When it … Read more

Measuring the complexity of SQL statements

Common measures of software complexity include Cyclomatic Complexity (a measure of how complicated the control flow is) and Halstead complexity (a measure of complex the arithmetic is). The “control flow” in a SQL query is best related to “and” and “or” operators in query. The “computational complexity” is best related to operators such as SUM … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)