say theres a table with 4 columns
col1 col2 col3 col4
val1 val2 4 3
val3 val1 5 4
val1 val4 6 2
I am trying to find out how many times value one is in one column based on a condition, and how many times its in the other column based on another condition. Unfortunately I cant use subqueries to do it cause of the hosting provider.
The below just sums the total times val1 appears multiplied by 2. Not really sure what I am doing wrong.
select count( col1 * ( col3 > col4 ) ) + ( col2 * ( col4 > col3 ) ) AS count FROM table WHERE col3 = 'val1' OR col4 = 'val1'
thanks
col1 col2 col3 col4
val1 val2 4 3
val3 val1 5 4
val1 val4 6 2
I am trying to find out how many times value one is in one column based on a condition, and how many times its in the other column based on another condition. Unfortunately I cant use subqueries to do it cause of the hosting provider.
The below just sums the total times val1 appears multiplied by 2. Not really sure what I am doing wrong.
select count( col1 * ( col3 > col4 ) ) + ( col2 * ( col4 > col3 ) ) AS count FROM table WHERE col3 = 'val1' OR col4 = 'val1'
thanks