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 2000 Forums
 SQL Server Development (2000)
 Counting Query and using the results to insert.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-11-27 : 23:48:27
Marc writes "I was wondering if it is possible to perform two different insert
statements depending on how many times a particular record is
found. For example, when I run:

SELECT number = COUNT(cart_id), cart_id
FROM cartitem
GROUP BY cart_id

... I get the number of occurances of a particular cart_id in
the table cartitem. I was wondering if it is possbible to
say, insert the data into one table if the cart_id occurs
less than five times, and into a different table if cart_id
occurs more than five times... or in general, just be able to
run two different SQL queries depending on the number of
of times cart_id occurs in the table cartitem."
   

- Advertisement -