SELECT client.name as ‘项目’,count(bill.bill_id) as ‘当日全责’,0 as ‘当日三者’,0 as ‘当月全责’,0 as ‘当月三者’,0 as ‘上月全责’,0 as ‘上月三者’,0 as ‘当日进场量’,0 as ‘当月累计进场量’ FROM sm_client client
LEFT JOIN sm_car car ON car.client_id = client.client_id
LEFT JOIN sm_bill bill ON bill.car_id = car.car_id
LEFT JOIN sm_company company ON company.company_id = bill.company_id
WHERE company.deleted IS NULL AND bill.deleted IS NULL AND car.deleted IS NULL AND client.deleted IS NULL
AND bill.duty_type != 1 AND bill.bill_type = 2 AND bill.date_created = ‘${curr_dt}’
GROUP BY client.name
写了这么一条语句,配置了curr_dt参数,点击运行查询发现报错,如下:
class net.sf.jsqlparser.statement.select.SetOperationList cannot be cast to class net.sf.jsqlparser.statement.select.PlainSelect (net.sf.jsqlparser.statement.select.SetOperationList and net.sf.jsqlparser.statement.select.PlainSelect are in unnamed module of loader ‘app’)
补充下,是这样的语句会报错
SELECT t.项目,sum(t.当日全责) as ‘当日全责’,sum(t.当日三者) as ‘当日三者’,(sum(t.当日全责)+sum(t.当日三者)) as 当日合计,sum(t.当月全责) as ‘当月全责’,sum(t.当月三者) as ‘当月三者’,(sum(t.当月全责)+sum(t.当月三者)) as 当月合计,sum(t.上月全责) as ‘上月全责’,sum(t.上月三者) as ‘上月三者’,(sum(t.上月全责)+sum(t.上月三者)) as 上月合计, sum(t.当日进场量) as ‘当日进场量’,sum(t.当月累计进场量) as ‘当月累计进场量’
FROM(
SELECT client.name as ‘项目’,count(bill.bill_id) as ‘当日全责’,0 as ‘当日三者’,0 as ‘当月全责’,0 as ‘当月三者’,0 as ‘上月全责’,0 as ‘上月三者’,0 as ‘当日进场量’,0 as ‘当月累计进场量’ FROM sm_client client
LEFT JOIN sm_car car ON car.client_id = client.client_id
LEFT JOIN sm_bill bill ON bill.car_id = car.car_id
LEFT JOIN sm_company company ON company.company_id = bill.company_id
WHERE company.deleted IS NULL AND bill.deleted IS NULL AND car.deleted IS NULL AND client.deleted IS NULL
AND bill.duty_type != 1 AND bill.bill_type = 2 AND bill.date_created = ‘${curr_dt}’
GROUP BY client.name
UNION
SELECT client.name as ‘项目’,0 as ‘当日全责’,count(bill.bill_id) as ‘当日三者’,0 as ‘当月全责’,0 as ‘当月三者’,0 as ‘上月全责’,0 as ‘上月三者’,0 as ‘当日进场量’,0 as ‘当月累计进场量’ FROM sm_client client
LEFT JOIN sm_car car ON car.client_id = client.client_id
LEFT JOIN sm_bill bill ON bill.car_id = car.car_id
LEFT JOIN sm_company company ON company.company_id = bill.company_id
WHERE company.deleted IS NULL AND bill.deleted IS NULL AND car.deleted IS NULL AND client.deleted IS NULL
AND bill.duty_type = 1 AND bill.bill_type = 2 AND bill.date_created = ‘${curr_dt}’
GROUP BY client.name