1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python replace || operator with CONCAT function using python

Discussão em 'Python' iniciado por Stack, Setembro 10, 2021.

  1. Stack

    Stack Membro Participativo

    I have an SQL query with the || operator and I want to rewrite the query using concat(). Can any one help in doing it because I have the query of || operator one inside the other?

    SQL_query="""select TIME.CURRENT_YEAR as Year1,
    TIME.QUARTER_KEY as Quarter_key,
    (( TIME .MONTH_EN || N' ') || cast( TIME .CURRENT_YEAR as varchar (4))) as Month__caption_,
    (( TIMEQUARTER.QUARTER_EN || N' ') || cast( TIME .CURRENT_YEAR as varchar (4))) as Quarter__caption_
    from
    [GOSALESDW]. TIME TIME ,
    [GOSALESDW]. TIMEQUARTER TIMEQUARTER
    where
    ( TIME .QUARTER_KEY = TIMEQUARTER.QUARTER_KEY) """


    I want to replace the || concat operator with the concat function.

    ( TIME .MONTH_EN || N' ') || cast( TIME .CURRENT_YEAR as varchar (4))) as Month__caption_,
    (( TIMEQUARTER.QUARTER_EN || N' ') || cast( TIME .CURRENT_YEAR as varchar (4))) as Quarter__caption_


    The required output is:

    CONCAT(CONCAT( TIME .MONTH_EN , N' ') , cast( TIME .CURRENT_YEAR as varchar (4))) as Month__caption_,
    CONCAT(CONCAT( TIME_QUARTER.QUARTER_EN , N' ') , cast( TIME .CURRENT_YEAR as varchar (4))) as Quarter__caption_

    Continue reading...

Compartilhe esta Página