我目前正在处理聚合查询,并希望将以下查询转换为QueryDSL。基本上它的作用是汇总为给定类别销售的所有产品,并获得带有计数的类别> X
select
tcc.catcode, tcc.catcount
from
(select
g.code catcode, count(*) catcount
from dwh_aggregated_order a
join cat_product_category g on g.id=a.product_category_id
group by g.code) tcc
where tcc.catcount > 2
答案 0 :(得分:0)
我认为查询可以简化为:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Joshua Brown</title>
<style>
* {
padding: 0;
margin: 0;
}
.top-menu {
width: 100%;
height: 80px;
background-color: #3f3535;
text-align: center;
}
h1 {
font-size: 42px;
font-weight: lighter;
font-family: sans-serif;
color: #2991d9;
/*
padding-left: 100px;
padding-top: 10px;
*/
}
li {
/*display: inline-block;*/
display: inline-flex;
justify-content: center;
float: right;
color: #FFF;
text-transform: uppercase;
border-style: 1px #6f6767 solid;
flex: auto;
text-align: center;
list-style-type: none;
border-right: 1px #6f6767 solid;
}
li:first-child {
border-style: none;
}
ul {
display: flex;
/*margin-bottom: 0;*/
margin: 0 auto;
}
.li {
/*padding-left: 50%*/
}
</style>
</head>
<body>
<div class="top-menu">
<h1>JOSHUA BROWN</h1>
<div class="li">
<ul>
<li>contact</li>
<li>news</li>
<li>concerts</li>
<li>videos</li>
<li>photos</li>
<li>bio</li>
<li>home</li>
</ul>
</div>
</div>
</body>
</html>
然后在querydsl中你可以使用SELECT g.code AS catcode
FROM dwh_aggregated_order AS a
INNER JOIN cat_product_category g ON g.id = a.product_category_id
GROUP BY g.code
HAVING COUNT(g.code) > 2;