You are here: COUNT, DISTINCT and SUM all in one « PHP SQL « IT news, forums, messages
COUNT, DISTINCT and SUM all in one

Posted by Brian on 10/14/90 11:48

Hi all (again)

More I get into MySQL and the more I read, the more I get confessed

I am trying to run a statement that does the following

Return a DISTINCT count of the number of records between two timestamps

SELECT count(DISTINCT dnote) as Total_Orders FROM $table WHERE (timestamp
BETWEEN 1146438000 AND 1148338800)

this works and brings back a result which I need

Now I need to say out of those returned records, how many of them had a
brand = 'X' and brand = 'Y' and brand = 'Z'

e.g.

Total_Orders = 900
Total where brand is X = 300
Total where brand is Y = 400
Total where brand is Z = 200

X+Y+Z should = Total_Orders

What I can't work out is how to say only SUM up the X,Y Z where a brand =
X,Y,Z


Thanks


Brian

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация