Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 19th, 2010  |  syntax: MySQL  |  size: 0.94 KB  |  hits: 7  |  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. SELECT dsa.Status                      AS StatusCode,
  2.        dsb.Id,
  3.        dsl.UserId,
  4.        dsl.Timestamp,
  5.        wf.Name                         AS WorkflowName,
  6.        Coalesce(u.Name, 'CompanyName') AS `Username`
  7. FROM   DataSource dsa,
  8.        Workflow wf
  9.        INNER JOIN DataSource dsb
  10.          ON wf.Id = dsb.WorkflowId
  11.             AND dsb.Id IN ( 0, 1, 2, 3,
  12.                             4, 5, 6, 7 )
  13.             AND dsb.Status = '203'
  14.              OR dsb.Status = '204'
  15.        INNER JOIN DataSourceActivityLog dsl
  16.          ON dsl.DataSourceId = dsa.Id
  17.             AND dsl.DataSourceId = dsb.Id
  18.             AND dsl.UserId = 1
  19.             AND dsl.Timestamp = (SELECT Max(t2.Timestamp)
  20.                                  FROM   DataSourceActivityLog AS dslt
  21.                                  WHERE  dslt.DataSourceId = dsl.DataSourceId)
  22.        LEFT JOIN User u
  23.          ON u.Id = dsl.UserId
  24. GROUP  BY dsl.Id
  25. ORDER  BY dsl.Timestamp DESC