Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Concatenate string to FIELD in SQL

Hi,

i have fileds YEAR and MONTH in a table and i want to create a string like "YEAR-MONTH" (2012-05 )

How can i do?

SQL SELECT

                      YEAR as `dat.year`,

                       MONTH as `dat.month`

                         [B.YEAR] &'-'& [B.MONTH] as `dat.timing`  ????

                    date([B.YEAR]+[B.MONTH],'YYYYMM') as `dat.timing`,   ?????

Thanks

1 Solution

Accepted Solutions
Gysbert_Wassenaar

That depends on the sql dialect of the source database. In Oracle you use two pipe symbols 'A' || 'B'. In SQL server you use the + sign iirc, 'A' + 'B'. If you're not sure, ask your local friendly database administrator.

Or, like Henric says, use a preceding load. Often so much simpler and more powerful.


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
hic
Former Employee
Former Employee

The best way is to use a Preceding Load:

Load

     Year,

     Month,

     Date(MakeDate(Year, Month),'YYYY-MM') as YearMonth;

SQL SELECT

     YEAR as Year,

     MONTH as Month

     FROM ...

HIC

Gysbert_Wassenaar

That depends on the sql dialect of the source database. In Oracle you use two pipe symbols 'A' || 'B'. In SQL server you use the + sign iirc, 'A' + 'B'. If you're not sure, ask your local friendly database administrator.

Or, like Henric says, use a preceding load. Often so much simpler and more powerful.


talk is cheap, supply exceeds demand