1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Field concat with group by

Discussion in 'SQL PL/SQL' started by fulgore, Oct 16, 2013.

  1. fulgore

    fulgore Guest

    Hello,

    I'm coming from a T-SQL background and I am new to oracle. I am trying to get month and year into one field here is my sql.
    SELECT COUNT(*) AS Total, concat(concat(SUBSTR(DATE_OF_DEATH, 5, 2), '-') DEATH_YEAR) "date"
    FROM CHEMS.TEST
    GROUP BY Total, concat(concat(SUBSTR(DATE_OF_DEATH, 5, 2), '-') DEATH_YEAR)

    I am getting a ORA-00909: invalid number of arguments. Any insights?
     
  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,347
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Code (SQL):
    SELECT COUNT(*) AS Total, SUBSTR(DATE_OF_DEATH, 5, 2)||'-'|| DEATH_YEAR) "date"
    FROM CHEMS.TEST
    GROUP BY SUBSTR(DATE_OF_DEATH, 5, 2)||'-'|| DEATH_YEAR)
     

    It's probably easier to use the || concatenation operator than the CONCAT function.