I do not deal with a lot of SQL, and most of the time I do CRUD operations. Sometimes I complicate things. So this question may be a beginners question, but I'm ready. I was just trying to figure it out for hours, and it is useless.
So imagine the following table structure:
> | ID | Col1 | Col2 | Col3 | .. | Col8 |
I want to select an identifier and a computed column. The calculated column has a range from 0 to 8 and contains the number of matches with the query. I also want to limit the result set to only including rows that have a certain number of matches.
So from this sample data:
> | 1 | 'a' | 'b' | 1 | 2 |
> | 2 | 'b' | 'c' | 1 | 2 |
> | 3 | 'b' | 'c' | 4 | 5 |
> | 4 | 'x' | 'x' | 9 | 9 |
I want to query on Col1 = 'a' OR Col2 = 'c' OR Col3 = 1 OR Col4 = 5, where the calculated result> 1 and the result set look like this:
> | ID | Cal |
> | 1 | 2 |
> | 2 | 2 |
> | 3 | 2 |
T-SQL SQL Server 2005, , DB.
.
Aaron