1.實現結果描述:
數據庫有id,name,crdate
1.先對數據按照crdate進行排序;
2.對name相同的進行分組(不同的name中crdate大的排前面,相同的name中crdate大的排前面)。
問題的詳細描述地址:先排序再分組再排序
2.效果展示
3.數據庫實現:先排序再分組,再排序
select t.name,t.crdate
from testor t
left join(
select name,max(crdate) as tr from(
select name, crdate
from testor
order by crdate desc
)q group by q.name
)o on t.name = o.name
order by o.tr desc,t.name,t.crdate desc;
4.組內元素合併
將name相同的進行合併(boottrap-table實現)
1.jsp頁面和js代碼
//1..jsp
//引入bootstrap-table所需要的js和css
<div class="main-cont o-auto" >
<table id="tableId" class="table-condensed" >
</table>
</div>
//2..js
function getTaleDetail(){
$("#tableId").bootstrapTable('destroy');
$('#flightDetail').bootstrapTable({
url: "請求路徑",
pagination: true,
contentType: "application/x-www-form-urlencoded",
dataType: "json",
method: "post",
striped:true,
queryParamsType:'',
sidePagination: "server",
pageNumber:1,
pageSize: 10, //分頁的頁面大小
pageList: [5, 10, 20],
queryParams: function getParams(params) {
//params.name= xx; 傳遞的參數
//params.crdate= xx;
return params;
},
clickToSelect:true,
buttonsAlign: "left",//按鈕對齊方式
onLoadSuccess : function(data) {
var data = $('#tableId').bootstrapTable('getData', true);
//合併單元格
mergeCells(data, "name", 1, $('#tableId'));
},
columns: [
{
title: "名字",
field: "name",
visible:true
},
{
title: "日期",
field: "crdate"
}, ],
locale: "zh-CN"//中文支持
});
}