Home Forums SQL Server 2012 SQL Server 2012 - T-SQL Subquery returned more than 1 value. This is not permitted when the subquery follows RE: Subquery returned more than 1 value. This is not permitted when the subquery follows

  • El_Mou (6/26/2013)


    its not the best practice to create a calculated field by calling this stored procedure

    so this is my context : i have a rapport who work perfectly but i want to add a calculated field

    formula of my field should be like this

    if UNITE_COUT_MATERIEL = 'Unité' then (SUPERFICIE_INTER_CULTURE / SUPERFICIE_INTER) * QUANTITE_MATERIEL

    if UNITE_COUT_MATERIEL = 'h' then (SUPERFICIE_INTER_CULTURE / SUPERFICIE_INTER) * DUREE_UTILISATION_MATERIEL

    HOW CAN I PUT HIS IN THE FONCTION EXPRESSION DESIGNER OF MY DATASET ?

    Something like this?

    select NewCol = (case UNITE_COUT_MATERIEL

    when 'Unité' then SUPERFICIE_INTER_CULTURE * QUANTITE_MATERIEL / SUPERFICIE_INTER

    when 'h' then SUPERFICIE_INTER_CULTURE * DUREE_UTILISATION_MATERIEL / SUPERFICIE_INTER

    else 0

    end)

    Notes

    1) I changed the order of the arithmetic operators, as it is usually better to multiply before dividing (reduced likelihood of rounding errors).

    2) I added an 'else return zero' condition, to catch other alternatives.

    --edit: fixed typo

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.