Toad World® Forums

Pull max value for each period in the other table

Let me explain the question in detail.

Table1:

Period1 - SEQ - Column1 - Column2

1- 1211212 - value1 - valu2

1- 122322 - value3 - value4

2 - 3434343- value5 - value6

2 - 344323 - value7 - value8

I want to pull the max(seq) for all the distinct periods. I need these details to compare to other table too. Please help me out.

Hi KrishBalu,
On 22/10/14 18:52, KrishBalu wrote:

Let me explain the question in detail.

Table1:

Period1 - SEQ - Column1 - Column2

1- 1211212 - value1 - valu2

1- 122322 - value3 - value4

2 - 3434343- value5 - value6

2 - 344323 - value7 - value8

I want to pull the max(seq) for all the distinct periods. I need these
details to compare to other table too. Please help me out.

I’m not sure all of your posting arrived safely here, the above is all I got, however…
To get the maximum sequence for each distinct period is easy:
select period1,max(seq)
from table1
group by period1
order by period1;
The order by is not necessary if you don’t care about the order the data are returned. The above will give you:
PERIOD1 MAX(SEQ)

select period1, max(seq) from table1 group by period1