In my table I have the column DESCRICAO
and the DATA_DE_CADASTRO
of items. In my Android application I would like to display the last 10 records that were recorded.
There are a number of attributes that must be reported when writing a new item, so this list is for you to choose an item from which you can copy some attributes to the other item that is currently being recorded since both items share the same information.
In this way I would like to have the last 10 records distinctly because it does not make sense in this case to present you with a list of 10 repeating items.
I make select by ordering it from the DTCAD column in descending order.
SELECT DSBEM FROM TAB ORDER BY DTCAD DESC
And it brings me the following data:
Andthat'sright.TELEFONEDIGITALCOMVISOR
wasthelastitemtobewritten,howeverwehaveseveralrepeateditems,butifyouselect
SELECTDISTINCTDSBEMFROMTABORDERBYDTCADDESC
Nowyou'rewrong.Where'sthedigitalphone?
Ihavealreadycreatedtheindexesforthedescriptionfordtcad,fordescriptionanddtcad.
Thecommand
SELECTDISTINCTDSBEMFROM(SELECTDSBEMFROMTABORDERBYDTCADdesc)LIMIT10
alsodoesnotwork.
Whatcouldbedone?
Onepossiblesolutionwouldbethisquery.
SELECTDISTINCTDTCAD,DSBEMFROMTABorderbydatetime(DTCAD)desc
Butthereturnisthis: