dush88c
dush88c

Reputation: 2106

Concatenate two columns in HANA database

Please give me an advice to convert below MSSQL VIEW to HANA VIEW

CREATE VIEW [dbo].[ViewSample]
AS
SELECT [column1] + ' / ' + [column2] AS CollectionLabel
FROM [dbo].[T1] T1
CROSS JOIN [dbo].[T2] T2

Thanks in advance

Upvotes: 2

Views: 60031

Answers (4)

cool Quazi
cool Quazi

Reputation: 248

CREATE VIEW [dbo].[ViewSample]
AS
SELECT [column1] || ' ' || [column2] AS CollectionLabel
FROM [dbo].[T1] T1
CROSS JOIN [dbo].[T2] T2

You should use '||' for concatenation

Upvotes: 2

Goldfishslayer
Goldfishslayer

Reputation: 450

There is also a concat operator which allows you to do that (||)

CREATE VIEW "dbo"."ViewSample"
    AS
    SELECT "column1" || ' / ' || "column2" AS CollectionLabel
    FROM "dbo"."T1" T1
    CROSS JOIN "dbo"."T2" T2

Upvotes: 11

How about CONCAT twice?

CREATE VIEW "dbo"."ViewSample"
    AS
    SELECT CONCAT("column1", CONCAT(' / ', "column2")) AS CollectionLabel
    FROM "dbo"."T1" T1
    CROSS JOIN "dbo"."T2" T2

Upvotes: 4

Caio Melzer
Caio Melzer

Reputation: 130

Just use '||' to concatenate string and columns.

Suppose that you need a full name of person, and in your table has two columns, the NAME and LAST_NAME.

SELECT NAME||' '||LAST_NAME FROM myTable

Upvotes: 4

Related Questions