title: MySQL: Incorrect syntax near 'ROUND'
body: <p>I'm trying to pull a data set from multiple tables and then calculate the age while pulling the data, but I'm unable to use round to calculate the age.</p>
  
  <p>Suggestions would be greatful!</p>
  
  <pre><code>    SELECT client.ClientNumber
           , client.ClientActive AS Active
           , invoice.ClientNumber
           , invoice.InvoiceDate AS InvoiceDate
           , invoicedetail.InvoiceNumber AS Invoice
           , invoicedetail.ClientNumber
           , invoicedetail.Extended AS Cost
           , invoicedetail.ServiceDate AS Serviced
      FROM
        dbo.client
        INNER JOIN dbo.invoice
          ON client.ClientNumber = invoice.ClientNumber
        INNER JOIN dbo.invoicedetail
          ON invoice.ClientNumber = invoicedetail.ClientNumber
      WHERE
        client.ClientActive = 'Y'
      GROUP BY
        client.ClientNumber
      , client.ClientActive
      , invoice.ClientNumber
      , invoice.InvoiceDate
      , invoicedetail.InvoiceNumber
      , invoicedetail.ServiceDate
      , invoicedetail.Extended
      , invoicedetail.ClientNumber
      , invoicedetail.ClientNumber
      ORDER BY
        InvoiceDate
  
      ROUND(DATEDIFF(hour,CASE WHEN [InvoiceDate]&gt;= GETDATE() THEN NULL ELSE [InvoiceDate] END, getdate())/8766.0,2) AS [ClientAge],
              (CASE WHEN ROUND(DATEDIFF(hour,CASE WHEN [InvoiceDate]&gt;= GETDATE() THEN NULL ELSE [InvoiceDate] END, getdate())/8766.0,2)&lt; 0.5 THEN '0-5 months'         
                       WHEN ROUND(DATEDIFF(hour,CASE WHEN [InvoiceDate]&gt;= GETDATE() THEN NULL ELSE [InvoiceDate] END, getdate())/8766.0,2) BETWEEN 0.5 AND 0.99 THEN '6-11 months'
                       WHEN ROUND(DATEDIFF(hour,CASE WHEN [InvoiceDate]&gt;= GETDATE() THEN NULL ELSE [InvoiceDate] END, getdate())/8766.0,2) BETWEEN 1 AND 5.99 THEN '1-5 years'
                       WHEN ROUND(DATEDIFF(hour,CASE WHEN [InvoiceDate]&gt;= GETDATE() THEN NULL ELSE [InvoiceDate] END, getdate())/8766.0,2) BETWEEN 6 AND 10.99 THEN '6-10 years'
                       WHEN ROUND(DATEDIFF(hour,CASE WHEN [InvoiceDate]&gt;= GETDATE() THEN NULL ELSE [InvoiceDate] END, getdate())/8766.0,2) BETWEEN 11 AND 15.99 THEN '11-15 years'
                       WHEN ROUND(DATEDIFF(hour,CASE WHEN [InvoiceDate]&gt;= GETDATE() THEN NULL ELSE [InvoiceDate] END, getdate())/8766.0,2)&gt;=16 THEN '16+ years'
                  END) as [ClientAgeGroup]    
  </code></pre>