0

我在下面写了一个mysql查询:

select * from (select a.country country_name,a.country_logo,
count(driver_id) total_empl
,(select count(*) from job where primary_location=a.country) open_jobs
,(select count(*) from catalog_driver where ifnull(country,'')=a.country and  (nationality='Omani' or nationality is null )) total_omani_in_oman
,round(((select count(*) from catalog_driver where ifnull(country,'')=a.country and  (nationality='Omani' or nationality is null ))/count(driver_id))*100,2) omani_percentage
,(select count(*) from catalog_driver where ifnull(country,'')=a.country and  (nationality!='Omani')) total_expat_in_oman
,round(((select count(*) from catalog_driver where ifnull(country,'')=a.country and  (nationality!='Omani'))/count(driver_id))*100,2) expat_percentage
,(select count(*) from catalog_driver where ifnull(country,'')=a.country and  (gender in ('Male','M')or gender is null) and (nationality='Omani' or nationality is null )) total_male_emp_in_oman
,(select count(*) from catalog_driver where ifnull(country,'')=a.country and  (gender in ('FeMale','F')) and (nationality='Omani' or nationality is null ))total_female_emp_in_oman
,(select count(*) from catalog_driver where ifnull(country,'')=a.country and  (gender in ('Male','M') or gender is null) and nationality!='Omani' ) total_male_expat_in_oman
,(select count(*) from catalog_driver where ifnull(country,'')=a.country and  (gender in ('FeMale','F')) and nationality!='Omani' ) total_female_expat_in_oman
 from 
(select cd.driver_id,cd.nationality,cd.gender,ifnull(cd.country,'')country,ccr.country_logo
from catalog_driver cd
left join catalog_country ccr on ccr.country_name=cd.country) a
group by a.country)aa where 1= 1

此查询计算按国家/地区分组的员工总数、空缺职位等。

但是,我在前端使用 Graphql。我已将其定义为countryLevelHistory模式定义语言 (SDL)。我在 graphql UI 中获取 countryLevelHistory 。当我运行它时,它给了我以下错误:

{
  "errors": [
    "Illegal value for GraphQLBigDecimal:7"
  ],
  "stackTrace": "graphql.GraphQLException: Illegal value for GraphQLBigDecimal:7\r\n\tat com.fuseim.graphql.type.Scalars$2.serialize(Scalars.java:88)\r\n\tat graphql.execution.ExecutionStrategy.completeValueForScalar(ExecutionStrategy.java:154)\r\n\tat 
...........
...........
...........
}

我有谷歌它,但没有得到好的结果。任何人有任何想法,让我知道。谢谢

4

1 回答 1

0

看来您使用的是 GraphQLBigDecimal,它是 java.math.bigdecimal。此类型应具有精度(即 7.1)。

在处理作业计数时,您可能希望使用 Int 类型(不需要精度)。

于 2017-11-23T23:57:07.067 回答