Need help converting MS ACCESS query to SQL 6.5

Need help converting MS ACCESS query to SQL 6.5

Post by Vincen » Thu, 17 Dec 1998 04:00:00



Hello,

The below SQL query from MS ACCESS works fine, but not when used in SQL
server. The error returns First is not a recognized built-in function
name. Can anyone tell me what's the equivalent of 'First' for SQL
server or is there another way of rewriting the query so it's more
standard and acceptable in both MS ACCESS and SQL server?
Thanks in advance for any suggestions or solutions.

SELECT TABLE_1.Name,
    SUM(TABLE_1.Views) AS SumOfViews,
    TABLE_1.InfoDate, TABLE_2.URL,
    TABLE_2.Company,
    TABLE_2.Stop,
    TABLE_2.Type,
    TABLE_2.Start,
    TABLE_2.Image,
    TABLE_2.Status
FROM TABLE_1 INNER JOIN
    TABLE_2 ON
    TABLE_1.Name = TABLE_2.Name
GROUP BY TABLE_1.Name,
    TABLE_1.InfoDate, TABLE_2.URL,
    TABLE_2.Company,
    TABLE_2.Stop,
    TABLE_2.Type,
    TABLE_2.Start,
    TABLE_2.Image,
    TABLE_2.Status
HAVING (((TABLE_1.Name) = 'MyCompany')
    AND ((TABLE_1.InfoDate)
    LIKE '%December%' AND (TABLE_1.InfoDate)
    LIKE '%December%'))
ORDER BY First(TABLE_1.ID)

Best Regards,
Vincent

 
 
 

Need help converting MS ACCESS query to SQL 6.5

Post by Delton Blackwel » Thu, 17 Dec 1998 04:00:00


SELECT TABLE_1.Name,
    SUM(TABLE_1.Views) AS SumOfViews,
    TABLE_1.InfoDate,
    TABLE_2.URL,
    TABLE_2.Company,
    TABLE_2.Stop,
    TABLE_2.Type,
    TABLE_2.Start,
    TABLE_2.Image,
    TABLE_2.Status,
    TABLE_1.ID
FROM TABLE_1, TABLE_2

WHERE TABLE_1.Name = TABLE_2.Name

GROUP BY TABLE_1.Name,
    TABLE_1.InfoDate,
    TABLE_2.URL,
    TABLE_2.Company,
    TABLE_2.Stop,
    TABLE_2.Type,
    TABLE_2.Start,
    TABLE_2.Image,
    TABLE_2.Status
HAVING (TABLE_1.Name = 'MyCompany'
    AND TABLE_1.InfoDate
    LIKE '%December%' )
ORDER BY TABLE_1.ID

Hope this helps


>Hello,

>The below SQL query from MS ACCESS works fine, but not when used in SQL
>server. The error returns First is not a recognized built-in function
>name. Can anyone tell me what's the equivalent of 'First' for SQL
>server or is there another way of rewriting the query so it's more
>standard and acceptable in both MS ACCESS and SQL server?
>Thanks in advance for any suggestions or solutions.

>SELECT TABLE_1.Name,
>    SUM(TABLE_1.Views) AS SumOfViews,
>    TABLE_1.InfoDate, TABLE_2.URL,
>    TABLE_2.Company,
>    TABLE_2.Stop,
>    TABLE_2.Type,
>    TABLE_2.Start,
>    TABLE_2.Image,
>    TABLE_2.Status
>FROM TABLE_1 INNER JOIN
>    TABLE_2 ON
>    TABLE_1.Name = TABLE_2.Name
>GROUP BY TABLE_1.Name,
>    TABLE_1.InfoDate, TABLE_2.URL,
>    TABLE_2.Company,
>    TABLE_2.Stop,
>    TABLE_2.Type,
>    TABLE_2.Start,
>    TABLE_2.Image,
>    TABLE_2.Status
>HAVING (((TABLE_1.Name) = 'MyCompany')
>    AND ((TABLE_1.InfoDate)
>    LIKE '%December%' AND (TABLE_1.InfoDate)
>    LIKE '%December%'))
>ORDER BY First(TABLE_1.ID)

>Best Regards,
>Vincent