Write Query The row with the highest ID Per day
You have 3 fields ID Date and Total Your table contains multiple rows for the same day which is valid data however for reporting purpose you need to show only one row per day. The row with the highest ID Per day should be returned the rest should be hidden from users( not returned)
Pankaj Kumar ChoudharyPosted Mar 18, 2015, 11:09 PM
Id Date_ Total
and write the query.
select Date_,Report.id,Total from report
left outer join
(select * from
(select Date_ as dat,max(id) as id from Report group by(Date_))Temp)Red
on
Report.id=Red.id
where
report.Date_=Red.dat
order by(Report.Date_)
and output is:
Date Id Total
2015-03-19 9 15000
2015-03-20 12 19000
2015-03-21 12 17000
2015-03-22 11 26000
If above is not according as you wish Then Please Explain what type of the output you want with an Example then i can understand your query very well.....