SHARE
TWEET

Untitled

a guest Sep 19th, 2010 7 Never
  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
RAW Paste Data
Top