March 23, 2014 at 12:24 pm
Hi guys,
I need some insight on how to emulate the below Ms. Access query to SQL.
Thanks in advance.
UPDATE [01 - MemberHomeAssignment] SET [01 - MemberHomeAssignment].[IBNR SNF Days] = IIf([01 - MemberHomeAssignment]![AuthDaysByMonth]<[01 - MemberHomeAssignment]![TotalDaysFromClaims],0,[01 - MemberHomeAssignment]![AuthDaysByMonth]-[01 - MemberHomeAssignment]![TotalDaysFromClaims]);
March 23, 2014 at 1:49 pm
have you looked at the T-SQL CASE statement....this may provide what you require
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
March 24, 2014 at 8:16 am
IF..ELSE is also a possibility since you've got a simple boolean condition.
____________
Just my $0.02 from over here in the cheap seats of the peanut gallery - please adjust for inflation and/or your local currency.
March 24, 2014 at 8:28 am
lshanahan (3/24/2014)
IF..ELSE is also a possibility since you've got a simple boolean condition.
You can't have an IF ELSE inside of an update statement. The IF operator is used to control flow of statements.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
March 24, 2014 at 8:33 am
It would be something like this.
UPDATE [01 - MemberHomeAssignment]
SET [IBNR SNF Days] =
case when AuthDaysByMonth < TotalDaysFromClaims then 0
else AuthDaysByMonth - TotalDaysFromClaims
end
Your code would be a million times easier to read and work with if you change the names to get rid of all the spaces.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
March 24, 2014 at 12:02 pm
Thanks for the replies guys, however, I had figured out the answer shortly after my post. My apologizes for not updating the thread.
March 24, 2014 at 12:09 pm
Briceston (3/24/2014)
Thanks for the replies guys, however, I had figured out the answer shortly after my post. My apologizes for not updating the thread.
Glad to hear you solved the issue.
for the benefit of others that may come across this question ...can you share your solution please?
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply