Hi All,
How can i write a query to count the number of records from a derived table. the derived table is a union of two table.
select msisdn from enrollOffer union DISTINCT select msisdn from enrollHistory
| SitePoint Sponsor |


Hi All,
How can i write a query to count the number of records from a derived table. the derived table is a union of two table.
select msisdn from enrollOffer union DISTINCT select msisdn from enrollHistory
Power of Knowledge
If you want to count msisdn that are present in both tables as well, use UNION ALL.Code:SELECT COUNT(*) FROM (SELECT msisdn FROM enrollOffer UNION SELECT msisdn FROM enrollHistory )
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget
Ah yes, forgot the aliasCode:SELECT COUNT(*) FROM (SELECT msisdn FROM enrollOffer UNION SELECT msisdn FROM enrollHistory ) AS a
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget


I have tried to put the alian asbut it is all failing. same error messageSELECT COUNT(cout) FROM (SELECT msisdn as cout FROM enrollOffer UNION SELECT msisdn as cout FROM enrollHistory );
Power of Knowledge


have a look at exactly where guido put the alias -- compare post #2 and post #4
Bookmarks