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 - 2002-07-30 : 09:36:57
|
| Mike writes "Within the select statement there are two case statements:CASE S.S_Adults WHEN 2 THEN R.R_Rate+P.PPAdult2 WHEN 3 THEN R.R_Rate+P.PPAdult2+P.PPAdult3 WHEN 4 THEN R.R_Rate+P.PPAdult2+P.PPAdult3+P.PPAdult4 ELSE R.R_RateEND as [Rate],CASE S.S_Adults WHEN 2 THEN D.Rate-R.R_Rate+P.PPAdult2 WHEN 3 THEN D.Rate-R.R_Rate+P.PPAdult2+P.PPAdult3 WHEN 4 THEN D.Rate-R.R_Rate+P.PPAdult2+P.PPAdult3+P.PPAdult4 ELSE D.Rate - R.R_RateEND as [Variance]I am trying to omit records where the variance = 0 showing only problem records. Can you put the second "Variance" case statement in the Where Clause and include the " <> 0 "??? I haven't had any luck yet trying.Does that make sense?" |
|
|
KHeon
Posting Yak Master
135 Posts |
Posted - 2002-07-30 : 10:35:47
|
| EDIT: Removed post cause I didn't read the question completely, and my answer was irrelavent.Kyle HeonPixelMEDIA, Inc.Senior Application Programmer, MCPkheon@pixelmedia.comEdited by - KHeon on 07/30/2002 10:37:57 |
 |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2002-07-30 : 11:10:02
|
| You can put the select as a derived tableselect * from ( selectCASE S.S_Adults WHEN 2 THEN R.R_Rate+P.PPAdult2 WHEN 3 THEN R.R_Rate+P.PPAdult2+P.PPAdult3 WHEN 4 THEN R.R_Rate+P.PPAdult2+P.PPAdult3+P.PPAdult4 ELSE R.R_Rate END as [Rate], CASE S.S_Adults WHEN 2 THEN D.Rate-R.R_Rate+P.PPAdult2 WHEN 3 THEN D.Rate-R.R_Rate+P.PPAdult2+P.PPAdult3 WHEN 4 THEN D.Rate-R.R_Rate+P.PPAdult2+P.PPAdult3+P.PPAdult4 ELSE D.Rate - R.R_Rate END as [Variance] from t ) as swhere s.rate <> 0and s.variance <> 0Btw, it is not a case statement, it is a case expression. There is a case statement in SQL which is not supported by T-sql. |
 |
|
|
|
|
|