JaedenRuiner
Member
I am looking for a way to store a numeric value based on a single row sql computation. I have a table that contains a field representing the count of another table:
I do other forms of percentage based analysis using this field:
What this does is simply grab the top 75% of the IDs from table1 ordered by the values in col1. THis works fine, but I would like to be able to compute the:
and store it in a variable, but 'DEFINE' doesn't work quite the way I want it too. My Idea was this:
I know that define doesn't seem to work like this but is there another way to achieve this result?
Code:
insert into count_table
(tbl1count)
select count(*) from table1;
Code:
select id from (
select
id,
col1, row_number() over (order by col1 desc) c1rn
from table1
)
where
col1 > 0 and c1rn <= (select tbl1count * 0.75 from count_table)
Code:
select tbl1count * 0.75 from count_table
Code:
DEFINE MyCount1 = (select tbl1count * 0.75 from count_table);
select id from (
select
id,
col1, row_number() over (order by col1 desc) c1rn
from table1
)
where col1 > 0 and c1rn <= &MyCount1;