Requirement Description: To display any data, first or last, according to a field or several fields.
Data styles such as:
Try to resolve:
-- Count (*) method (only shows the number of bars is 1, more than 1 filter all) Select * from where inch (Selectfromgroupby hasCount(id)= 1)
The above method will show only 1 records, but the repetition does not keep one of them, also filtered out.
So, we need to change a bit and provide three solutions:
First, by the row_number by the repeating field grouping sorts, then displays 1th, uses the AB table way:
--Select A.* from T4 A, (Selectthrough order by as from T4) bwhere= and B.nid=1
Second, the same method, by Row_number by repeating the field of grouping sorting, and then display 1th. But using sub-query mode:
Select A.*fromselect row_number ()throughorder by as Nid,* from T4 ) awhere a.nid= 1
Third, by grouping to take the minimum or maximum value for resolution.
Select * from where inch (Selectminfromgroup by self-coding)
This is the simplest approach, but the ID requirement must be a number that can be calculated for min or max. If there is no pure digital ID, you can use Row_number to establish NID first, then Min.
Select Row_number ()throughorder by as Nid,*from T4
The above three kinds of schemes have the same effect.
SQL to re-display the first data to display a single piece of data