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
 Transact-SQL (2000)
 Ordering counts with multiple tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-09-10 : 09:12:51
Robert writes "I have 2 tables. One is a list of customers and the other is a list of visits by the customers. I need to show a list of customers but order them by the number of visits of each customer. If cust #1 has 4 records on the visits table, I need him to show up above someone with only 3 visit records. The total visits is merely a record count of records with his custid. Right now I get the customer records then while looping through them to build the table, for each one I have to get a record count of the visits. This leaves me with the data I need but the table is ordered by name."
   

- Advertisement -