Question about case then and where with parameter

  • Hello Experts,

    I have the following querie using case then statement for one of my fields as it follows,

    My question is, I need to add another condition but this one has to ask the user the date. This query has to run per day and I need to add where B.tdate = parameter.

    How can I acomplish that?

    SELECT B.tName as Name_, B.tdate,

    CAST(B.FldNumeric_24216 AS nvarchar(MAX)) AS Concepto,

    ((CASE FldNumeric_24216

    WHEN '18' THEN 'Administrative Fee'

    WHEN '19' THEN 'Application Fee'

    WHEN '13' THEN 'Cap & Gown'

    WHEN '14' THEN 'Certificado De Estudios Sep'

    WHEN '11' THEN 'Clinical Rotations'

    WHEN '17' THEN 'Co-op'

    WHEN '10' THEN 'Deans Letter'

    WHEN '1' THEN 'Debt'

    WHEN '20' THEN 'Diploma Translation'

    WHEN '3' THEN 'ECFMG Certification'

    WHEN '42' THEN 'Electives'

    WHEN '21' THEN 'Examen Extraordinario'

    WHEN '22' THEN 'Examen Profesional'

    WHEN '4' THEN 'Fed-Ex'

    END )) AS Description_

    FROM B

  • montse 22199 (1/31/2013)


    Hello Experts,

    I have the following querie using case then statement for one of my fields as it follows,

    My question is, I need to add another condition but this one has to ask the user the date. This query has to run per day and I need to add where B.tdate = parameter.

    How can I acomplish that?

    SELECT B.tName as Name_, B.tdate,

    CAST(B.FldNumeric_24216 AS nvarchar(MAX)) AS Concepto,

    ((CASE FldNumeric_24216

    WHEN '18' THEN 'Administrative Fee'

    WHEN '19' THEN 'Application Fee'

    WHEN '13' THEN 'Cap & Gown'

    WHEN '14' THEN 'Certificado De Estudios Sep'

    WHEN '11' THEN 'Clinical Rotations'

    WHEN '17' THEN 'Co-op'

    WHEN '10' THEN 'Deans Letter'

    WHEN '1' THEN 'Debt'

    WHEN '20' THEN 'Diploma Translation'

    WHEN '3' THEN 'ECFMG Certification'

    WHEN '42' THEN 'Electives'

    WHEN '21' THEN 'Examen Extraordinario'

    WHEN '22' THEN 'Examen Profesional'

    WHEN '4' THEN 'Fed-Ex'

    END )) AS Description_

    FROM B

    Your query as posted has no conditions, it will return every row from B. If you want to return only certain rows add a where clause.

    where B.tdate = parameter

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • you were right. Thanks for this response. It is working fine now.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply