Group By value to store as a Variable

28 views Asked by At

i got this query where i require the value retrieve from group by to store as a variable.

My script:

sqlread ="SELECT Count(*) as NoOfRec ,([Customer_Name])"&_
  " FROM [TheCat13]"&_
  " WHERE [Customer_Number] = '"&_
  ""&CustomerNumber&"'"&_
  "GROUP BY [Customer_Name]"

rs.Open sqlread, myConn
if NoOfRec = 1 then
        'Exists
        CustomerName = rs.fields("Customer_Name")
else
         CustomerName ="Not Found"
end if
rs.Close

Please advise how do i store as variable.

Result to store in a variable

0

There are 0 answers