Let's suppose I have 2 tables like the above.Code:myTable1 (id) name (1) Tom (2) Jane (3) Chris (4) Judy (5) Mary (6) Jack (7) James (8) Bill myTable (pom) kid (1) 2 (3) 1 (3) 4 (5) 8
The code1 below produces the result1 below.
I can count the number of records in result1 with the code below.Code:code1 select name from myTable1 left join myTable on myTable1.id=myTable.pom where myTable.pom is not null order by name result1 Chris Chris Mary Tom
Since Chris comes 2 times in result1, I like the code3 and its result3 below.Code:code2 select count(*) as count from myTable1 left join myTable on myTable1.id=myTable.pom where myTable.pom is not null result2 4
Now I have a problem. i.e, How can I count the number of records in result3?Code:select distinct name from myTable1 left join myTable on myTable1.id=myTable.pom where myTable.pom is not null order by name result3 Chris Mary Tom
The following code4 is one of my trials for it. but it still says 4 instead of 3.
Code:code4 select distinct count(*) as count from myTable1 left join myTable on myTable1.id=myTable.pom where myTable.pom is not null result4 4



Reply With Quote



Bookmarks