欢迎投稿

今日深度:

sql语句查询时间的方式比较(代码实例),sql语

sql语句查询时间的方式比较(代码实例),sql语句


sql语句查询时间的方式比较(代码实例)

SELECT
    e.id AS "id",
    e.enterprise_name AS "enterpriseName",
    y.industry_name AS "industryName",
    d.district_name AS "districtName",
    v.level_value AS "levelValue",
    v.sumScore as "sumScore"
FROM
    
        (
            (
                enterprise e
                LEFT JOIN industry y ON e.industry_id = y.id
            )
            LEFT JOIN district d ON e.district_id = d.id
        )


        LEFT JOIN 

                (
                        SELECT i.enterprise_id,SUM(i.index_score) sumScore,l.level_value  from index_enterprise_year i LEFT JOIN level_enterprise_year l ON i.enterprise_id = l.enterprise_id
                        AND l. YEAR = i.year where  i.year=2017 GROUP BY i.enterprise_id 
                )  v 

        ON  e.id=v.enterprise_id
where 
    e.enterprise_status = 10
ORDER BY sumScore DESC
LIMIT 10

\

SELECT
    e.id AS "id",
    e.enterprise_name AS "enterpriseName",
    e.business_registration_no AS "businessRegistrationNo",
    e.organization_code AS "organizationCode",
    e.unified_credit_code AS "unifiedCreditCode",
    e.legal_person_name AS "legalPersonName",
    e.enterprise_telephone AS "enterpriseTelephone",
    e.registered_address AS "registeredAddress",
    e.longitude AS "longitude",
    e.dimension AS "dimension",
    e.industry_id AS "industryId",
    y.industry_name AS "industryName",
    e.district_id AS "districtId",
    d.district_name AS "districtName",
    e.formula_id AS "formulaId",
    e.enterprise_status AS "enterpriseStatus",
    SUM(i.index_score) sumScore,
    l.level_value
FROM
    (
        (
            (
                enterprise e
                LEFT JOIN industry y ON e.industry_id = y.id
            )
            LEFT JOIN district d ON e.district_id = d.id
        )
        LEFT JOIN level_enterprise_year l ON e.id = l.enterprise_id
        AND l. YEAR = 2017
    )
LEFT JOIN index_enterprise_year i ON e.id = i.enterprise_id
AND i. YEAR = 2017
GROUP BY
    e.id
HAVING
    e.enterprise_status = 10
ORDER BY
    sumScore DESC
LIMIT 10

\

两条语句时间相差75倍,了解下原因

www.htsjk.Com true http://www.htsjk.com/Sql_Server/24603.html NewsArticle sql语句查询时间的方式比较(代码实例),sql语句 sql语句查询时间的方式比较(代码实例) SELECT e.id AS id, e.enterprise_name AS enterpriseName, y.industry_name AS industryName, d.district_name AS districtNa...
评论暂时关闭