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 |
|
kamii47
Constraint Violating Yak Guru
353 Posts |
Posted - 2007-03-31 : 03:00:53
|
| select myname,mydate,myduedate,mymonthCal,mydaysleftCal,mycategoryCal,mydateyear_monthCal from tbltestmyname and mydate are in the database wh ich are value who are not allowed null.mymonthCal,mydaysleftCal,mycategoryCal and mydateyear_monthCal are calculated column on the basis of myname and mydatemyname mydate myduedate aa 3/31/2005 12:00:00 am 5/31/2005 12:00:00 am 12/1/2005 12:00:00 am 12/30/2006 12:00:00 am cc 12/12/2006 12:00:00 am expected resultsetmyname mydate mymonthCal, mydaysleftCal, mycategoryCal, mydateyear_monthCal aa 3/31/2005 bb 12/1/2005 cc 1,mymonthCalif mydate is 12-31-2005 12:00:00 am THEN mymonth should be Dec-052,mydaysleftCalif myduedate is empty it will return 39,126other wise it will first check if myname is empty [remeber not null just ''] it will return empty string elsereturn the difference of current date with mydate 3,mycategoryCalit is calculated by the excel formula on the bases mydaysleft=IF(mydaysleftCal="","",IF(mydaysleftCal<=0,0,IF(mydaysleftCal<=10,"0 - 10",IF(mydaysleftCal<=30,"11 - 30",IF(mydaysleftCal<=60,"31 - 60",IF(mydaysleftCal<=90,"61 - 90",IF(mydaysleftCal>90,"90+","")))))))4,mydateyear_monthCalif mydate is 3/31/2005 12:00:00 am and month is less then 10 then mydateyear_monthCal should be like 2005_3 where 2005 is the year and 3 is the monthif month is greater then or equal to 10 then mydateyear_monthCal should be like 2005_x3 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-05 : 05:47:20
|
| 1 Where do you want to show formatted data? If you use front end application, use format function there2 Post table structure, sample data and expected result3MadhivananFailing to plan is Planning to fail |
 |
|
|
tishri
Yak Posting Veteran
95 Posts |
Posted - 2007-04-05 : 06:12:43
|
| use case statement to replace excel IF statementTCC |
 |
|
|
|
|
|
|
|