我在下面写了一个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。我已经在模式定义语言(SDL)中将其定义为countryLevelHistory。我在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
...........
...........
...........
}


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

最佳答案

似乎您正在使用GraphQLBigDecimal,它是一个java.math.bigdecimal。此类型应具有精度(即7.1)。

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

07-27 13:25