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.
| Author |
Topic |
|
ashishkukreja
Starting Member
16 Posts |
Posted - 2007-08-23 : 03:26:42
|
| Hello sirI just started working in SQL Server so please don't mind when my question is irritating please help me out for thisI have a table having a coloumnsMonth-----------------Size----------------------IssueApril-07---------------750----------------------2676April-07--------------1000--------------------1223April-07--------------180---------------------3439April-07--------------90---------------------23562May-07---------------750----------------------254May-07--------------375--------------------454May-07--------------180---------------------454May-07--------------90---------------------3434Something like that it is just a example o my table I have data in ThousandsSo know what I want to do is I want to add one more coloumn where i want to use if statment something like thatIssue_cases: IIf([size]=1000,[Issue]/9,IIf([size]=750,[Issue]/12,IIf([size]=375,[Issue]/24,IIf([size]=180,[Issue]/48,IIf([size]=90,[Issue]/100)))))now you please tell me that for this what I have to do I have to create a view or procedure or anything else and how?Please tell meI thing I explain my question bestI required your help immediatelyThanksEver SmilingAshishYou Have to Loss Many Times to Win Single Time |
|
|
Koji Matsumura
Posting Yak Master
141 Posts |
Posted - 2007-08-23 : 05:46:09
|
| SELECT Month, Size, Issue,NewColumn = 1.0 * Size /CASEWHEN Size = 1000 THEN 9WHEN Size = 750 THEN 12WHEN Size = 375 THEN 24::END |
 |
|
|
ashishkukreja
Starting Member
16 Posts |
Posted - 2007-08-23 : 05:56:57
|
| Thanks for your replybut where I have to put a table nameplease replyThanksEver smilingAshishYou Have to Loss Many Times to Win Single Time |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2007-08-23 : 07:31:09
|
| Did you try at the end of the code?Read the links in my signature.[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
mohit_sme
Starting Member
13 Posts |
Posted - 2007-08-23 : 16:51:19
|
| Hi AshishI can suggest creating a new computed column for this and put your calculation over there.ThanksMohit Nayyarhttp://mohitnayyar.blogspot.com |
 |
|
|
renu
Starting Member
47 Posts |
Posted - 2007-10-04 : 07:28:39
|
| select case c1when 1000 then c2/9when 750 then c2/12when 180 then c2/48endfrom tablenamewhere c1=1000 |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-10-04 : 07:46:58
|
| [code]Create View V1asSelect Month, Size, Issue, 1.0 * Size / CASE WHEN Size = 1000 THEN 9 WHEN Size = 750 THEN 12 WHEN Size = 375 THEN 24 ... End As SomeColumnFrom SomeTable[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|
|
|