我正在尝试找出一种查询条件的语法,这似乎很常见。
下面的typedef以一对多对多(作者)关系存储代表作者的代理的ID值。我想在从Author模式获取详细信息的同时提取代理的名称。
type Author {
id: ID!
firstName: String
middleInitial: String
lastName: String
posts: [Post]
agent: ID
}
因此封闭的查询(返回所有作者的列表)如下所示:
{
authors {
firstName
lastName
agent
}
}
这给了我座席的ID。我该如何使用相同的查询从类似于上面的typedef中获取代理的名称?
答案 0 :(得分:3)
mysql> select * from wc_revenue;
+--------------+---------------+-------------+
| invoice_date | gross_revenue | net_revenue |
+--------------+---------------+-------------+
| 2018-06-28 | 1623.99 | 659.72 |
| 2018-06-27 | 112414.65 | 38108.13 |
| 2018-06-26 | 2518.74 | 1047.14 |
| 2018-06-25 | 475805.92 | 172193.58 |
| 2018-06-22 | 1151.79 | 478.96 |
| 2018-07-02 | 150.00 | 100.00 |
| 2018-07-05 | 350.00 | 250.00 |
| 2018-08-07 | 600.00 | 400.00 |
| 2018-08-09 | 900.00 | 600.00 |
+--------------+---------------+-------------+
mysql> SELECT month(invoice_date) as MTH, invoice_date, SUM(gross_revenue) AS gross_revenue, SUM(net_revenue) AS net_revenue
FROM wc_revenue
GROUP BY MTH, invoice_date WITH ROLLUP;
+------+--------------+---------------+-------------+
| MTH | invoice_date | gross_revenue | net_revenue |
+------+--------------+---------------+-------------+
| 6 | 2018-06-22 | 1151.79 | 478.96 |
| 6 | 2018-06-25 | 475805.92 | 172193.58 |
| 6 | 2018-06-26 | 2518.74 | 1047.14 |
| 6 | 2018-06-27 | 112414.65 | 38108.13 |
| 6 | 2018-06-28 | 1623.99 | 659.72 |
| 6 | NULL | 593515.09 | 212487.53 |
| 7 | 2018-07-02 | 150.00 | 100.00 |
| 7 | 2018-07-05 | 350.00 | 250.00 |
| 7 | NULL | 500.00 | 350.00 |
| 8 | 2018-08-07 | 600.00 | 400.00 |
| 8 | 2018-08-09 | 900.00 | 600.00 |
| 8 | NULL | 1500.00 | 1000.00 |
| NULL | NULL | 595515.09 | 213837.53 |
+------+--------------+---------------+-------------+
答案 1 :(得分:0)
查询看起来像这样。我不确定您的Agent typedef是什么样,但是您知道了
=IFERROR(IF(INDEX(D:D,AGGREGATE(14,6,ROW($D$1:D1)/(($B$1:B1 = B2)*($C$1:C1 = C2)),1))<D2,"Close","Open"),"Open")