-1

I want to select starting semester of the student.

select distinct (stdcode),altcode,name,admdate,sem_code
,min(startsem)
from V_ALLSTUDATAAA
GROUP BY stdcode,altcode,name,degree_code,sem_code
order by altcode;

Desired Results:

enter image description here

Sample Data is attached below. https://docs.google.com/spreadsheets/d/1-oqXgGfhIiLwWKLpUx94P9n1hXUAUE3dn3jAPV8HQ_k/edit?usp=sharing

MT0
  • 143,790
  • 11
  • 59
  • 117
  • Your query seems working fine to get desired results. Just include ADMDATE in GROUP BY statement. – Arun Nov 01 '21 at 06:03
  • but i want to find first semester system show all semester of all minimum date. – Secular Earth Nov 01 '21 at 06:15
  • Its a bit hard to digest what you really want here - because it looks like every student started on 08-sep-08. Also, the best way to get support is to give the data in such a way that its easy for people to replicate it on their own system. So you should give us the "create table" statement and then an "insert" statement for each row. – Connor McDonald Nov 01 '21 at 06:17
  • Please check new updated sample data. – Secular Earth Nov 01 '21 at 06:30
  • 1
    Does this answer your question? [Fetch the row which has the Max value for a column](https://stackoverflow.com/questions/121387/fetch-the-row-which-has-the-max-value-for-a-column). Or this: [GROUP BY with MAX(DATE)](https://stackoverflow.com/questions/3491329/group-by-with-maxdate) – astentx Nov 01 '21 at 07:48

1 Answers1

0

One option is to use a correlated subquery; something like this:

select a.stdcode, a.altcode, a.name, a.admdate, a.degree_code, a.sem_code, a.startsem
from v_allstudataaa a
where a.startsem = (select min(b.startsem)
                    from v_allstudataaa b
                    where b.stdcode = a.stdcode
                   );
Littlefoot
  • 131,892
  • 15
  • 35
  • 57