Re: [SQL] Having the sum of two queries

2007-07-17 Thread Dani Castaños
Thank you all! My problem has been solved in another way... because the inner queries had left outer joins and so on, and I finally have had to do two queries and treat results by PHP. Again... thank you all! ---(end of broadcast)--- TIP 2: Don'

Re: [SQL] Having the sum of two queries

2007-07-16 Thread Hélder M . Vieira
... SELECT tot.status, COUNT(total) FROM( QUERY A UNION QUERY B ) AS tot GROUP BY tot.status But it doesn't works. It doesn't add the total columns with the same status... ... I guess you have two problems, if I understand what you're trying to do. - As Roberto Spier noted, 'sum' would be be

Re: [SQL] Having the sum of two queries

2007-07-16 Thread Roberto Spier
Dani Castaños escreveu: ... And have the result of both added. I've tried something like SELECT tot.status, COUNT(total) Should be SELECT tot.status, SUM(total) FROM( QUERY A UNION QUERY B ) AS tot GROUP BY tot.status But it doesn't works. It doesn't add the total columns with the same s

Re: [SQL] Having the sum of two queries

2007-07-16 Thread Achilleas Mantzios
Στις Δευτέρα 16 Ιούλιος 2007 14:06, ο/η Dani Castaños έγραψε: > Hi all! > > I want to do something like this: > > SELECT status, COUNT( status ) AS total > FROM users > GROUP BY status > > UNION > > SELECT status, COUNT(status) AS total > FROM imported_users > GROUP BY status > > > And have the res

[SQL] Having the sum of two queries

2007-07-16 Thread Dani Castaños
Hi all! I want to do something like this: SELECT status, COUNT( status ) AS total FROM users GROUP BY status UNION SELECT status, COUNT(status) AS total FROM imported_users GROUP BY status And have the result of both added. I've tried something like SELECT tot.status, COUNT(total) FROM( QU