简体   繁体   English

显示数字最高的行,即使它是相同的

[英]Show rows with highest number, even if it's the same

I'm using the following SQL我正在使用以下 SQL

SELECT 
    testjob.id AS id,
    testjob.EndTime AS Date,
    testsuitecollectionname,
    testsuitecollection,
    TestSuiteName,
    TestSuite
FROM
    Testreportingdebug.testjob
        LEFT JOIN
    testsuitecollection ON testsuitecollection.id = testjob.testsuitecollectionid
        LEFT JOIN
    testsuitecollectionlink ON testsuitecollection.id = testsuitecollectionlink.testsuitecollection
        LEFT JOIN
    testsuite ON testsuite.id = testsuitecollectionlink.testsuite
WHERE
    testjob.Engine = 'SeqZap'
        AND TestSuiteName IN (
        'AlertManagement')
        AND testjob.EndTime IN ('2020-05-18 05:18:58','7305', '2020-03-18 04:57:31', 'gin_mixit_simulated', '34', 'AlertManagement', '987'
, '2020-05-17 16:39:03', '2020-03-03 18:07:28', '2020-05-18 16:07:44')
        AND testjob.id IN ('13382', '13372', '5921', '13391', '7305')
ORDER BY TestSuiteName;

and I get the following Rows from table从表中得到以下行

Is it possible to filter this table so I get only the rows marked here: Wanted rows是否可以过滤这个表,所以我只得到这里标记的行:想要的行

NOTE: I can have multiple TestSuiteNames , and they have to always with the highest date, and show all rows for it.注意:我可以有多个TestSuiteNames ,它们必须始终使用最高日期,并显示它的所有行。

Could it be possible to use MAX(testjob.EndTime), and then if there is more than one Max date for that specific TestSuiteName , then it shows them, instead not showing?是否可以使用 MAX(testjob.EndTime),然后如果该特定TestSuiteName有多个 Max 日期,那么它会显示它们,而不是显示?

SELECT 
    testjob.id AS id,
    testjob.EndTime AS Date,
    testsuitecollectionname,
    testsuitecollection,
    TestSuiteName,
    TestSuite
FROM
    Testreportingdebug.testjob
        LEFT JOIN
    testsuitecollection ON testsuitecollection.id = testjob.testsuitecollectionid
        LEFT JOIN
    testsuitecollectionlink ON testsuitecollection.id = testsuitecollectionlink.testsuitecollection
        LEFT JOIN
    testsuite ON testsuite.id = testsuitecollectionlink.testsuite
WHERE
    testjob.Engine = 'SeqZap'
        AND TestSuiteName IN (
        'AlertManagement')
        AND testjob.EndTime IN ('2020-05-18 05:18:58','7305', '2020-03-18 04:57:31', 'gin_mixit_simulated', '34', 'AlertManagement', '987'
, '2020-05-17 16:39:03', '2020-03-03 18:07:28', '2020-05-18 16:07:44')
        AND testjob.id IN ('13382', '13372', '5921', '13391', '7305')
        AND testsuitecollectionname = 'ceops1_pwm64_circ1'
ORDER BY TestSuiteName;

How about that?那个怎么样?

Added (one line above Order by): AND testsuitecollectionname = 'ceops1_pwm64_circ1'添加(排序依据上方的一行): AND testsuitecollectionname = 'ceops1_pwm64_circ1'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM