Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Below is the sample code.How can I create a view and set PriceType as a varchar?CREATE VIEW VoteCount ASSELECT VoteCount_Base.fi_answerID AS Bank_ID, Count(VoteCount_Base.fi_Session_id) AS AbsoluteVoteCount, case when Count([fi_Session_id]) > 6 then Count([fi_session_id]) else '<7' end AS PriceType,Cast ([PriceType] , AS NVARCHAR(50) FROM VoteCount_BaseGROUP BY VoteCount_Base.fi_answerID;rizo
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2012-08-03 : 10:12:45
Cast the number to VARCHAR as in:
CREATE VIEW VoteCount AS SELECT VoteCount_Base.fi_answerID AS Bank_ID, COUNT(VoteCount_Base.fi_Session_id) AS AbsoluteVoteCount, CASE WHEN COUNT([fi_Session_id]) > 6 THEN CAST(COUNT([fi_session_id]) AS VARCHAR(32)) ELSE '<7' END AS PriceType FROM VoteCount_Base GROUP BY VoteCount_Base.fi_answerID;