因此,我试图将结果限制为仅下了2个或更多订单的结果,但我不确定要获得该结果我做了什么或需要做什么。
这是到目前为止我得到的:
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
export class MyComponent {
constructor(
private route: ActivatedRoute
) {}
ngOnInit() {
const firstParam: string = this.route.snapshot.queryParamMap.get('firstParamKey');
const secondParam: string = this.route.snapshot.queryParamMap.get('secondParamKey');
}
}
答案 0 :(得分:2)
只需添加:
having count(distinct o.orderid) >= 2
我认为您需要的查询是:
SELECT C.CustomerID, C.CompanyName,
OrdersPlaced = COUNT( O.OrderID),
TotalPrice = SUM( D.Quantity * D.UnitPrice)
FROM Customers C INNER JOIN
Orders O
ON C.CustomerID = O.CustomerID INNER JOIN
[Order Details] D
ON O.OrderID = D.OrderID
WHERE O.OrderID >= 3
GROUP BY C.CustomerID, C.CompanyName;
您还需要从OrderId
中删除GROUP BY
。