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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Use of embedded case statement

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-01-08 : 08:52:51
Himanshu writes "I am unable to get the result by wrttine following query by using embedded case statement. what is wrong in this

select Proj_No,
Year,
Qtr,
(case when Year = 2003 then
case Qtr when 1 then (isNull(sum(Cptl_sftwr_pln),0) + isnull(sum(cptl_hrdwr_pln),0)) end
else
111111
end) AS '2003Q1'
from Proj_Finance
where Proj_No = 73
group by Proj_No, Year, Qtr
order by Proj_No"

nr
SQLTeam MVY

12543 Posts

Posted - 2003-01-08 : 09:19:58
What are you trying to get and what is the result from this?

should put out 111111 for year <> 2003
null for year = 2003 qtr <> 1

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-01-08 : 09:37:00
Yes, in regular old english, what results do you want? make sure you cover all possiblities.

- Jeff
Go to Top of Page
   

- Advertisement -