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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-07-13 : 07:48:17
|
| Don Donoghue writes "Im using sql on a application and an accounts tableIm trying to work out statstics of how long it takes apps to turn into accounts. My code works out the time by using the months between function and then I update a monthe field accordingly i.e month1 is an account that was set up in less than a month and the month2 column is an acount is set up in 1 to 2 months. You can see below what I do with a scipt but is there a way I can do this with a case statement update mortgage_pipeline APPset MONTH1 = 1WHERE months_between (account_opened_date,application_date)<1;commit;update mortgage_pipeline APPset MONTH2 = 1WHERE months_between (account_opened_date,application_date)<2AND months_between (account_opened_date,application_date)>=1;commit;update mortgage_pipeline APPset MONTH3 = 1WHERE months_between (account_opened_date,application_date)<3AND months_between (account_opened_date,application_date)>=2;commit;" |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2005-07-13 : 08:35:44
|
| yuk? how about redesign the database. I am sure there is a "App started" date somewhere. Probably a "Became Account" date field too. Now just calculate how long it was between the two dates, voila! There is your statistic, without needing 2 more columns.*need more coffee*SELECT * FROM Users WHERE CLUE > 0(0 row(s) affected) |
 |
|
|
|
|
|