吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1408|回复: 6
收起左侧

[求助] orcal可以mysql不行

[复制链接]
username11 发表于 2021-4-26 15:58
再一次来求助了~请求大佬 就是这一段代码,在orcal可以,现在需要转为mysql请问应该怎么改呢

[SQL] 纯文本查看 复制代码
SELECT
	MAX(COUNT(DISTINCT qodi_Id))
FROM
	(
		SELECT
			qod.qodi_Id,
			qod.qodi_lsro_id
		FROM
			Qk_Order_Distribute qod
		LEFT JOIN LG_STORE_ROOM lsr ON lsr.lsro_id = qod.qodi_lsro_id
		LEFT JOIN qk_Order qo ON qo.qord_id = qod.qord_id
		LEFT JOIN qk_Literature ql ON ql.qlit_id = qo.qlit_id
		WHERE
			qod.acct_id = 22
AND qo.qord_Year = '2021'			
	) qod
LEFT JOIN (
	SELECT
		qui.lsro_Id
	FROM
		Qk_Unit_Info qui
	LEFT JOIN qk_Year_Vol_Period qyvp ON qyvp.qyvp_id = qui.qyvp_id
	LEFT JOIN qk_Order qo ON qo.qord_id = qyvp.qord_id
	LEFT JOIN qk_Literature ql ON ql.qlit_id = qui.qlit_id
	WHERE
		qui.acct_id = 22
	AND qui.quin_Flow_State = 2 
	AND qo.qord_Year = 2021
	
) qui ON qui.lsro_id = qod.qodi_lsro_id
WHERE
	qui.lsro_id IS NULL
GROUP BY
	 qod.qodi_lsro_id

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

wifengqingyang 发表于 2021-4-26 16:02
设置别名之类的,前面带个as 试试
 楼主| username11 发表于 2021-4-26 16:04
origamiii 发表于 2021-4-26 16:34
太长了懒得看 = = 但我大致看了下,只是普通的left join这种语法是sql通用的 一般莫得问题。一般oracle可以,mysql不行的话,准是函数有点问题,比如: MAX(COUNT(DISTINCT qodi_Id))  这里。
树荫底下的太阳 发表于 2021-4-26 16:36
本帖最后由 树荫底下的太阳 于 2021-4-26 16:41 编辑

[SQL] 纯文本查看 复制代码
select max(c) from (
SELECT COUNT(DISTINCT qodi_Id) c
FROM (
         SELECT qod.qodi_Id,
                qod.qodi_lsro_id
         FROM Qk_Order_Distribute qod
                  LEFT JOIN LG_STORE_ROOM lsr ON lsr.lsro_id = qod.qodi_lsro_id
                  LEFT JOIN qk_Order qo ON qo.qord_id = qod.qord_id
                  LEFT JOIN qk_Literature ql ON ql.qlit_id = qo.qlit_id
         WHERE qod.acct_id = 22
           AND qo.qord_Year = '2021'
     ) qod
         LEFT JOIN (
    SELECT qui.lsro_Id
    FROM Qk_Unit_Info qui
             LEFT JOIN qk_Year_Vol_Period qyvp ON qyvp.qyvp_id = qui.qyvp_id
             LEFT JOIN qk_Order qo ON qo.qord_id = qyvp.qord_id
             LEFT JOIN qk_Literature ql ON ql.qlit_id = qui.qlit_id
    WHERE qui.acct_id = 22
      AND qui.quin_Flow_State = 2
      AND qo.qord_Year = 2021
) qui ON qui.lsro_id = qod.qodi_lsro_id
WHERE qui.lsro_id IS NULL
GROUP BY qod.qodi_lsro_id) a;
树荫底下的太阳 发表于 2021-4-26 16:38
mysql中不支持max嵌套count
 楼主| username11 发表于 2021-4-26 17:22
树荫底下的太阳 发表于 2021-4-26 16:36
[mw_shl_code=sql,true]select max(c) from (
SELECT COUNT(DISTINCT qodi_Id) c
FROM (

感谢 已经成功了 多加了一层 和您一样
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-26 05:43

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表