Brightlane's reporting system builds order reference strings by combining a prefix and an order identifier.
Write a query to return the result of concatenating 'ORDER-' and '1042' with the || operator.
Output:
- A single row with one column,
order_ref, containing the concatenated string.
Schema · ecommerce 5 tables
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
'ORDER-' || '1042' AS order_ref The shape
'ORDER-' || '1042' joins the two string literals end-to-end and returns the single concatenated value 'ORDER-1042'. That is the order reference the reporting system needs.
Clause by clause
SELECT 'ORDER-' || '1042' AS order_refevaluates the concatenation once and labels the resulting columnorder_ref. The||operator takes the two adjacent string literals and returns a single string with the right operand pasted onto the end of the left. There is noFROMbecause both values come straight from the prompt as literals; nothing is being read from a table.
Why this and not CONCAT('ORDER-', '1042')
Both expressions return the same string on this input. || reads as a binary operator between two values, which matches the shape of the operation: two strings, one join. CONCAT is variadic and takes a function-call form, which carries more visual weight than the work being done. Either is correct on a clean two-operand join with no NULLs in play. The choice between them becomes load-bearing only when a NULL might appear, which is the next problem.
You practiced || — the strict two-operand concatenation operator; both sides must be present to produce a result.