DB2 ⭐ Featured
👁 0

Q: What is CTE (Common Table Expression)?

Answer:
CTE defines temporary result set. WITH cte_name AS (SELECT...) SELECT * FROM cte_name. Improves readability. Can be recursive for hierarchies. Multiple CTEs comma-separated. Referenced in main query. Scope is single statement.
JCL ⭐ Featured
👁 0

Q: What is the difference between COND and IF/THEN/ELSE?

Answer:
COND tests return codes to skip steps (negative logic - skips IF true). IF/THEN/ELSE tests conditions to execute steps (positive logic). IF supports complex expressions, COND is simpler but confusing. IF preferred for readability. COND on JOB affects all steps; on EXEC affects that step.
DB2 ⭐ Featured
👁 0

Q: Explain COALESCE function

Answer:
COALESCE returns first non-NULL argument. COALESCE(col1, col2, 'default'). Useful for NULL handling. VALUE is synonym. Common: COALESCE(nullable_col, 0) for calculations. Can chain multiple expressions.
COBOL
👁 0

Q: Explain COMPUTE statement

Answer:
COMPUTE performs arithmetic with expression syntax. COMPUTE RESULT = (A + B) * C / D. Supports + - * / ** operators. ROUNDED option rounds result. ON SIZE ERROR handles overflow. Clearer than separate ADD/SUBTRACT/MULTIPLY/DIVIDE for complex formulas.
COBOL
👁 0

Q: How to use intrinsic functions?

Answer:
COBOL-85 intrinsic functions: FUNCTION LENGTH(field), FUNCTION CURRENT-DATE, FUNCTION UPPER-CASE(field), FUNCTION NUMVAL(field), FUNCTION MOD(a,b), FUNCTION INTEGER-OF-DATE(date). Use in expressions or with COMPUTE. Return values only, no side effects.
DB2
👁 0

Q: What is CASE expression?

Answer:
CASE provides if-then logic. CASE WHEN cond1 THEN val1 WHEN cond2 THEN val2 ELSE default END. Simple CASE: CASE col WHEN 'A' THEN 'Active' END. Use in SELECT, WHERE, ORDER BY. Powerful for transformations.