Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

How do I translate this into SQL Server:

-Sum((12=[GroupNum])*[BoardStatus]) AS G12
FROM QryAllBoardsByPacketIDs INNER JOIN tBsReportGroups ON QryAllBoardsByPacketIDs.NominalLengthMetric=tBsReportGroups.NomLenMet
GROUP BY QryAllBoardsByPacketIDs.ParentPacketID, QryAllBoardsByPacketIDs.GradeID, QryAllBoardsByPacketIDs.NominalWidthMetric, QryAllBoardsByPacketIDs.NominalThicknessMetric;

Kind regards,


share|improve this question
I think you need to explain what this part does (12=[GroupNum])*[BoardStatus]. It looks like you are summing all rows where GroupNum is 12. If that is a case then you could use sum(BoardStatus) and add a where clause where GroupNum = 12. –  Mikael Eriksson Jun 18 at 5:21

1 Answer 1

Not quite sure I follow as I rarely use Access, but I believe this is what you're looking for:

   CASE WHEN 12=[GroupNum] THEN 1 ELSE 0 END
   * [BoardStatus]
   ) AS G12

CASE...WHEN is the inline "if" of T-SQL.

share|improve this answer
I would like to ask if the -SUM has any translation –  user1124937 Jun 19 at 6:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.