title: How to find Number of records inserted into sql table
body: <p>I have following sql statement running in side stored procedure . This query inserts data into TABLE_AB, those data are retried from AAA and BBB table. When this procedure is running, I want to find out number of records inserted into TABLE_AB. If no data is included, I want to return now matching data was found to insert into TABLE_AB. Could anybody help to understand how to get it done. Thanks in advance for any help</p>
  
  <blockquote>
  <pre><code>INSERT INTO TABLE_AB (X,Y,Z, TOTAL_CNT, TOTAL_AMT)
  SELECT X,Y,Z, TOTAL_CNT, TOTAL_AMT
  FROM(
  
  SELECT A.X, A.Y, A.Z , COUNT(1), SUM(AMT)
  FROM AAA A WHERE A.X = 1 
  GROUP BY A.X, A.Y, A.Z 
  UNION ALL
  
  SELECT B.X, B.Y, B.Z , COUNT(1), SUM(AMT)
  FROM BBB B WHERE A.X = 1 
  GROUP BY B.X, B.Y, B.Z
  
  ) AS AB
  GROUP BY AB.X, AB.Y , AB.Z
  </code></pre>
  </blockquote>