Skip to Content
0
Former Member
Jul 14, 2008 at 02:57 AM

Count Record in RIN1 table

36 Views

Hi can anybody help me with my query. I want count the Baseref field from RIN1 table, want to Count DocEntry field that have greater to 1 in the Baseref field. This query below is running :

SELECT BaseRef,

COUNT(DocEntry)

FROM

(SELECT

dbo.RIN1.BaseRef,

dbo.RIN1.DocEntry

FROM

dbo.RIN1

GROUP BY

dbo.RIN1.BaseRef,

dbo.RIN1.DocEntry) CountBaseRef

GROUP BY

BaseRef,

But when used to DECLARE command like below :

error message appears : "Only one expression can be specified in the select list when the subquery is not introduced with EXISTS."

DECLARE @Counter INT

SET @Counter =

( SELECT BaseRef,

COUNT(DocEntry)

FROM

(SELECT

dbo.RIN1.BaseRef,

dbo.RIN1.DocEntry

FROM

dbo.RIN1

GROUP BY

dbo.RIN1.BaseRef,

dbo.RIN1.DocEntry) CountBaseRef

GROUP BY

BaseRef )

Please guide me thank you very much!.

Clint