I have a known number, x and several named columns (ix, col1, col2, col3...) and need to select a single value from either col1, col2, or col3 from each row (not necessarily the same column) where the total adds up to the known number x. I am having a difficult time trying to figure out the logic for this.
There is no chance of multiple result sets using the numbers in the columns, but one column from each row MUST be returned, with all columns returned adding up to the number X.
Ideally it would be something like this:
SELECT * as results FROM table WHERE sum(results) = number
however I can't use * in the sum statement, and it is possible that more than one result from each column (although being in separate rows) could be returned. SO I can't do Select col1, col2 col3 etc. As well, the table has a primary key IX and 64 columns, so any select case statement, or such won't work