c# - how to print the last record of each admission number in sql server -
i having database have stored fees collected several students.
i having column like:-
admno name class section tuitionfee sjs001 arjun nursery 3000 sjs002 akash nursery 2000 sjs001 arjun nursery 1000 sjs005 baldev class-ii b 5000
there may same admission number might have paid several times tuition fees. want print last value of entered admission number how can this.
if want print last admission, need add column admissiondate
. can this:
select top(1) admno,name,class,section,tuitionfee, admissiondate table_name admno = 'sjs001' order admissiondate desc
this sql server specific syntax. there other ways achieve result, using max(admissiondate)
in subquery.
select * t1 t1.admno = 'sjs001' , admissiondate = (select max(admissiondate) t2 t1.admno = t2.admno)
Comments
Post a Comment