vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi all, I'm trying to implement a strawberry technique for having the last item of a linked table. Unfortunately, I can't get it to work as I take 2 values for defining as in some cases the value can be the same (a date field). Here is the strawberry part: select .... from d inner join de fs1 on d.idd = fs1.idd LEFT JOIN de fs2 ON fs1.idd = fs2.idd AND fs1.datee < fs2.datee .....where fs2.idd is null Now the problem is that in some cases the fs1.datee is the same than the fs2.datee. In this case, I'd like to check also the fs1.idtype < fs2.idtype I've tried adding more tests in the join but doesn't work: worse, it return more values: select .... from d inner join de fs1 on d.idd = fs1.idd LEFT JOIN de fs2 ON (fs1.idd = fs2.idd AND (fs1.datee < fs2.datee and fs1.idtype > fs2.idtype)) .....where fs2.idd is null I need your help to get the maximum fs1 by using the datee and if 2 records have the same date, use also the fs1.idtype by using the biggest value thanks Bob |