none
(Sumber: milist SQL Server) Statement CASE WHEN RRS feed

  • Pertanyaan

  • Dear Para master SQL,
    Saya lagi ada kendala di Statement Case SQL saya.

    Select QSNo,Valid = CASE Validity When ' 7 ' then '7 Hari setelah penawaran kami buat'
                                     CASE Validity When '15' then '15 Hari setelah penawaran kami buat'
                                     Else
                                         '30 Haris setelah penawaran kami buat'
                                     END,
                   Whse
    From T_QSSH


    Waktu saya execute, selalu muncul "Incorrect syntax near the keyword 'CASE'"
    Mohon bantuannya
    Terima Kasih


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Rabu, 27 Juni 2012 08.52
    Moderator

Jawaban

  • Hi,

    Bagaimana kalau gini:

    Select QSNo, CASE Validity 

                                        When ' 7 ' then '7 Hari setelah penawaran kami buat'
                         

                When '15' then '15 Hari setelah penawaran kami buat'
                            Else '30 Haris setelah penawaran kami buat'
                            END AS Valid, Whse
    From T_QSSH
     

    Dijawab oleh: JOhan


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Rabu, 27 Juni 2012 08.53
    Moderator

Semua Balasan

  • Hi,

    Bagaimana kalau gini:

    Select QSNo, CASE Validity 

                                        When ' 7 ' then '7 Hari setelah penawaran kami buat'
                         

                When '15' then '15 Hari setelah penawaran kami buat'
                            Else '30 Haris setelah penawaran kami buat'
                            END AS Valid, Whse
    From T_QSSH
     

    Dijawab oleh: JOhan


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Rabu, 27 Juni 2012 08.53
    Moderator
  • Terima kasih bang joe, ternyata CASE nya tidak perlu diulang lagi.

    Masalah Solve.


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Rabu, 27 Juni 2012 08.53
    Moderator