Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 1.26 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Reading evaluated data from MySQL database
  2. ID
  3. status (can contain values 0, 1, 2)
  4. timepstamp
  5. text
  6. note
  7. owner
  8.        
  9. number of entries
  10.  number of entries where status=0
  11.  number of entries where status=1
  12.  number of entries where status=2
  13.  number of entries where LENGTH(note)>0
  14.  minimum timestamp
  15.  maximum timestamp
  16.        
  17. SELECT status, timestamp, LENGTH(note)>0 WHERE owner="name";
  18.        
  19. SELECT
  20.     MIN(timestamp) AS mintime,
  21.     MAX(timestamp) AS maxtime,
  22.     COUNT(*) AS number,
  23.     ...
  24. WHERE owner="name"
  25.        
  26. COUNT(WHERE status=0) AS inactive
  27.     COUNT(IF(status=1)) AS active
  28.     ...
  29.        
  30. SELECT
  31.     COUNT(*) AS total,
  32.     SUM(IF(status=0, 1, 0)) AS stat0,
  33.     SUM(IF(status=1, 1, 0)) AS stat1,
  34.     SUM(IF(status=2, 1, 0)) AS stat2,
  35.     SUM(IF(LENGTH(note)>0, 1, 0)) AS notes,
  36.     MIN(timestamp) AS mintime,
  37.     MAX(timestamp) AS maxtime
  38. FROM tbl_name
  39. WHERE owner="name"
  40. GROUP BY owner
  41.        
  42. SELECT
  43. MIN(`timestamp`) AS `mintime`,
  44. MAX(`timestamp`) AS `maxtime`,
  45. COUNT(`ID`) AS `number`,
  46. (SELECT COUNT(`ID`) FROM `Table` WHERE `owner` = 'owner' AND `status` = 0) AS `inactive`,
  47. (SELECT COUNT(`ID`) FROM `Table` WHERE `owner` = 'owner' AND `status` = 1) AS `active`,
  48. (SELECT COUNT(`ID`) FROM `Table` WHERE `owner` = 'owner' AND LENGTH(`note`)>0) AS `longentries`
  49. FROM `Table`
  50. WHERE `owner` = 'name'