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 |
|
MGsqluser
Starting Member
1 Post |
Posted - 2008-02-22 : 17:45:21
|
| I have a stored procedure in which I pass certain parameters.Based on my parameter list I want to select rows that meet any of the criteria specified and I also want to find which rows met which of the criteia.Can anyone suggest me a way of doing this? This is what my query will look like:SELECT j2821.RepName, j2821.LogEntryID, j2821.Transaction2821ID, j2821.TransactionPercentOfNetWorth, j2821.AnnualIncome, j2821.TimeHorizon, j2821.RegistrationType,j2821.ProductTypeFROM Transaction2821Journals j2821 INNER JOIN Journals j ON j2821.LogEntryID=j.LogEntryIDWHERE j.JournalTypeID = 8 AND j2821.DateClientSignature >= '2/5/2008'AND j2821.DateClientSignature <= '2/21/2008'AND (j2821.RegistrationType = 'Qualified')OR (j2821.Amount > 1000) OR (j2821.TimeHorizon IN ('5-10 Years') OR (j2821.Income > 1000) I want to know which of the OR conditions were met for all the rows returned.Any help appreciated. |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2008-02-22 : 19:11:06
|
[code]SELECT j2821.RepName ,j2821.LogEntryID ,j2821.Transaction2821ID, j2821.TransactionPercentOfNetWorth ,j2821.AnnualIncome ,j2821.TimeHorizon ,j2821.RegistrationType ,j2821.ProductType ,Case When j2821.Amount > 1000 then 'Amount>1000' When k2821/Income > 1000 then 'Income>1000' When j2821.TimeHorizon = '5-10 Years' then '5 to 10 YRS' End as CriteriaMetFROM Transaction2821Journals j2821 INNER JOIN Journals j ON j2821.LogEntryID=j.LogEntryIDWHEREj.JournalTypeID = 8 AND j2821.DateClientSignature >= '2/5/2008'AND j2821.DateClientSignature <= '2/21/2008'AND (j2821.RegistrationType = 'Qualified')OR (j2821.Amount > 1000) OR (j2821.TimeHorizon IN ('5-10 Years') OR (j2821.Income > 1000)[/code] Poor planning on your part does not constitute an emergency on my part. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-23 : 01:00:00
|
| Also you should express dates in universal YYYYMMDD format to avoid confilct with local date settingsMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|