Forum Replies Created

Viewing 10 posts - 1 through 10 (of 10 total)

  • RE: Join two tables

    Great... it is working fine.

    thanks for all.

  • RE: Separate one column in many columns

    Kingston Dhasian (6/14/2013)


    Change the final SELECT statement to something like this

    SELECT*, CAST( ( game1 + game2 + game3 + game4 + game5 ) / 5.0 AS NUMERIC(10,1) ) AS [percent]

    FROMcte_Students

    Thanks...

  • RE: Separate one column in many columns

    ChrisM@Work (6/13/2013)


    -- sample data

    ;WITH students (ID_Student, Name, rate) AS (

    SELECT 1, CAST('Chipper Jones' AS nchar(30)), CAST('678*9' AS nchar(5)) UNION ALL

    SELECT 2, 'Mike Piazaa', '98***' UNION ALL

    SELECT 3, 'Barry Bonds', '678**'...

  • RE: Separate one column in many columns

    Kingston Dhasian (6/13/2013)


    It happened because the data types for columns game1, game2,...game5 were taken as VARCHAR

    The below code will avoid the issue

    ; WITH cte_Students AS

    (

    SELECT*,

    CASE WHEN SUBSTRING(rate, 1, 1) =...

  • RE: Separate one column in many columns

    Kingston Dhasian (6/12/2013)


    You can use a CTE or a Derived table like this

    ; WITH cte_Students AS

    (

    SELECT*,

    CASE WHEN SUBSTRING(rate, 1, 1) = '*' THEN '10' ELSE SUBSTRING(rate, 1, 1) END AS...

  • RE: Separate one column in many columns

    Pelon (6/4/2013)


    Kingston Dhasian (6/4/2013)


    Something like this..

    SELECT*,

    CASE WHEN SUBSTRING(rate, 1, 1) = '*' THEN '10' ELSE SUBSTRING(rate, 1, 1) END AS game1,

    CASE WHEN SUBSTRING(rate, 2, 1) = '*' THEN '10' ELSE...

  • RE: Separate one column in many columns

    Thanks for your help.

    Now I have a doubt, I would like to add the numbers of each column and after add them i want divide them to get ...

  • RE: Separate one column in many columns

    Kingston Dhasian (6/4/2013)


    Something like this..

    SELECT*,

    CASE WHEN SUBSTRING(rate, 1, 1) = '*' THEN '10' ELSE SUBSTRING(rate, 1, 1) END AS game1,

    CASE WHEN SUBSTRING(rate, 2, 1) = '*' THEN '10' ELSE SUBSTRING(rate,...

  • RE: Split a column

    Sean Lange (6/2/2013)


    You don't need to split this to achieve the results you are looking for. All you need is a simple replace.

    select replace(Name, '*', ' ')

    Yes, it works !

    Thank...

  • RE: Split a column

    Thanks, everyone.

Viewing 10 posts - 1 through 10 (of 10 total)