Jump to content

nickspick

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

nickspick's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. It looks like you want the 'number of messages' populated with the number of messages 'from' people. For starters don't name a column 'from' as its a reserved word. Renaming 'from' to 'sentFrom' the following should do the job: [color=blue][pre]SELECT     sentFrom AS chat_with,     COUNT(*) AS number_of_messages FROM     testing GROUP BY     sentFrom[/pre][/color] Using COUNT and GROUP BY, it returns the number of rows grouped into each. [i]N[/i]W
  2. Hi, I've got a table with a column that stores prices that vary considerably. These prices will be used to create options for the user to select a price range. Rather than presenting every number I want to group the numbers into ranges and display these along with a count of how many results fall into each range. I've been able to achieve the same concept with datestamps (See example) but am stumped with what to use for just plain numbers. [pre] [color=blue]SELECT DATE_FORMAT(FROM_UNIXTIME(date), '%Y') as new_date, COUNT(*) AS numRows FROM table GROUP BY new_date[/color] [/pre] The above example will group all timestamps into years and also count how records are contain within each group. I'd like a similar thing for numbers but grouping them into 1000s or 10000s. Any ideas? Many thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.