Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 syntax trouble

Author  Topic 

viperbyte
Posting Yak Master

132 Posts

Posted - 2011-12-13 : 09:51:24
Good morning all. I'm trying to convert a query from Access to T-SQL and I'm having trouble with handling the brackets. I have a whole mess of these thing to convert. Can someone super please take a look at this one the most smallest and sincere one I have to convert and convert it? With that done I'll be able to take it from there and do the rest and I'll be grateful.

SELECT CountyTbl.FIPS, Count([2009ArtsNonProfits].RULEDATE) AS CountOfRULEDATE, Sum([2009ArtsNonProfits].TOTREV2) AS AllRev
FROM 2009ArtsNonProfits INNER JOIN CountyTbl ON [2009ArtsNonProfits].FIPS=CountyTbl.FIPS
GROUP BY CountyTbl.FIPS
HAVING (((Count([2009ArtsNonProfits].RULEDATE))>19));

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-12-13 : 09:59:01
I believe all you need to do is get rid of them:
SELECT CT.FIPS,
Count(ANP.RULEDATE) AS CountOfRULEDATE
, Sum(ANP.TOTREV2) AS AllRev
FROM 2009ArtsNonProfits ANP
INNER JOIN CountyTbl CT ON ANP.FIPS=CT.FIPS
GROUP BY CT.FIPS
HAVING Count(ANP.RULEDATE)>19


Jim

I aliased the tables to make it easier for me to read.

Everyday I learn something that somebody else already knew
Go to Top of Page

viperbyte
Posting Yak Master

132 Posts

Posted - 2011-12-13 : 10:47:48
Howdy Jim. Thanks. Your advice led me to focus that removing the brackets was all that was needed and to look for something else to be the problem. The problem was that the table name stared with numbers. I renamed the table to start with a letter. So with the renamed table and removed brackets it worked. Thanks
Go to Top of Page
   

- Advertisement -