I have 2 tables, size and cost. My query does a count with a greater than comparison of cost and counts different sizes.
table1: size u
table2: cred t
Here is my query:
select u.size as size
,count(u.size) * .4 as "40% of size"
,count(case when (t.cred * 12) > (t.inc *.3) then 1 end) as "30% cost"
from cred t
join size u on t.id = u.id
group by u.size
The result is as follows:
|Size||40% of size||30% cost|
I want the query to show a 'Y' if the cost column is larger than the size column and a 'N' if it is smaller. Here would be the result I'm looking for:
|Size||40% of size||30% cost||Y/N|
Is there a way to show this? I tried to use the following, but I get this: Boolean value cannot be operated with non-Boolean value.
,case when ((t.cred * 12) > (t.inc * .3)) > (count(u.size) * .4) then 'Y' else 'N' end as "Y/N"
Not sure if I need to do a subquery?