I have myTables like the above.Code:myTable1 (id) 1 2 3 4 5 myTable1 (in) (out) 2 1 3 1 4 1 5 2
When a variables is 1, the query below produces the result below.
I like to know the number of the result above in SQL.Code:code SELECT id FROM myTable1 mm WHERE mm.id<>1 AND mm.id IN (SELECT myTable2.in FROM myTable2 WHERE myTable2.out=1) result 2 3 4
The trial code1 below seems not to work.
If I should use GROUP BY for getting COUNT, how can I use GROUP BY in this case?Code:trial code1 SELECT count(*) as count FROM myTable1 mm WHERE mm.id<>1 AND mm.id IN (SELECT myTable2.in FROM myTable2 WHERE myTable2.out=1) target result 3
The trial code2 and the trial code3 below are all failed.
Code:trial code2 SELECT count(*) as count FROM myTable1 mm WHERE mm.id<>1 AND mm.id IN (SELECT myTable2.in FROM myTable2 WHERE myTable2.out=1) GROUP BY myTable2.outCode:trial code3 SELECT count(*) as count FROM myTable1 mm WHERE mm.id<>1 AND mm.id IN (SELECT myTable2.in FROM myTable2 WHERE myTable2.out=1) GROUP BY myTable2.in







Bookmarks