Divide Max of one column with value in current record

T

Tod

I have a table with two columns. Each is a column of numbers, any
numbers. Like this:

Col1 Col2
1 8
2 4
4 4
3 7
7 1

For each record, I want to divide the value in Col1 with the MAXIMUM
value of Col2. In this example, each value in Col1 will be divided by
8.

How do I do this?

tod
 
M

Marshall Barton

Tod said:
I have a table with two columns. Each is a column of numbers, any
numbers. Like this:

Col1 Col2
1 8
2 4
4 4
3 7
7 1

For each record, I want to divide the value in Col1 with the MAXIMUM
value of Col2. In this example, each value in Col1 will be divided by
8.


You can use a subquery:

SELECT (SELECT Max(X.Col2) FROM table As X) As maxval,
T.Col1,
T.Col1 / maxval
FROM table As T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top