Solved

building a string in a query

Posted on 2013-06-08
2
276 Views
Last Modified: 2013-06-09
I am trying to build a string in q query I will use for a column Description. How would I properly use case belw?

SELECT     11 AS Expr1, od.DeliveryDateRequest, od.GrowthStageID, od.Quantity, od.ProductID, od.UnitPrice, od.TotalPrice, od.SpecialDiscount, 
                      gs.GrowthStageName, p.Productname, 
p.Productname + ' - ' + gs.GrowthStageName  
case when od.SpecialDiscount <> 0 then + od.SpecialDiscount + ' Discount' end  AS Comments
FROM         WW.ClientOrderDetails AS od INNER JOIN
                      WW.Products AS p ON od.ProductID = p.ProductID INNER JOIN
                      WW.GrowthStage AS gs ON od.GrowthStageID = gs.GrowthStageID
WHERE     (od.OrderID = 401025)

Open in new window

0
Comment
Question by:Shawn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
Thomasian earned 500 total points
ID: 39232422
SELECT
	11 AS Expr1
	, od.DeliveryDateRequest
	, od.GrowthStageID
	, od.Quantity
	, od.ProductID
	, od.UnitPrice
	, od.TotalPrice
	, od.SpecialDiscount
	, gs.GrowthStageName
	, p.Productname
	, p.Productname + ' - ' + gs.GrowthStageName + 
	case when od.SpecialDiscount <> 0 then CAST(od.SpecialDiscount as varchar) + ' Discount' else '' end AS Comments
FROM         WW.ClientOrderDetails AS od INNER JOIN
                      WW.Products AS p ON od.ProductID = p.ProductID INNER JOIN
                      WW.GrowthStage AS gs ON od.GrowthStageID = gs.GrowthStageID
WHERE     (od.OrderID = 401025)

Open in new window

0
 
LVL 1

Author Closing Comment

by:Shawn
ID: 39233193
thank you
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question