sql query to select columns from multiple tables code example
Example 1: sql select merge multiple values
DECLARE @combinedString VARCHAR(MAX)
SELECT @combinedString = COALESCE(@combinedString + ', ', '') + column_name
FROM table_name
WHERE ID = 1234
SELECT @combinedString as StringValue
Example 2: sql select rows with different values in one column
SELECT *
FROM YourTable
WHERE ARIDNR IN (
SELECT ARIDNR
FROM YourTable
GROUP BY ARIDNR
HAVING COUNT(*) > 1
)