select SUM(pass_count) ,SUM(fail_count),SUM(blocked_count),SUM(no_run_count)
from TAble1(nolock) table1
where owasp_id = (1,2,3,4,5,8)
inner join
Table 2 table2
on
TAble1.build_detail_id = table2.build_detail_id
where
TAble1.build_detail_id in(
select top 6 bdt.build_detail_id from table3 bdt order by 1 desc)
and table1.test_run_id=1
I am getting syntax error and I would like to get the sum of passcount ,fail count where owasp_id= 1,2,3,4,5,8 and do inner join with table 2 for build detail id. Can any one help in this?
There are three syntax errors, the first two breaks the query, the third is a strong recommendation:
WHERE
should come after FROM
and any JOIN
clauses. owasp_id = (1,2,3,4,5,8)
should be owasp_id IN (1,2,3,4,5,8)
as you're supplying multiple values. WITH
for table hints ( NOLOCK
) is deprecated and should be avoided.So the query should probably look like this:
select SUM(pass_count) ,SUM(fail_count),SUM(blocked_count),SUM(no_run_count)
from Table1 WITH (nolock) table1
inner join Table2 table2 on TAble1.build_detail_id = table2.build_detail_id
where owasp_id IN (1,2,3,4,5,8)
AND Table1.build_detail_id in(
select top 6 bdt.build_detail_id from table3 bdt order by 1 desc)
and table1.test_run_id=1
Whether the query will work as intended I can't say, but it should be correct syntactically at least.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.