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)
 From an account table to an user table

Author  Topic 

Dang1337
Starting Member

3 Posts

Posted - 2005-08-17 : 11:07:38
Hello, I'm looking for some help on creating a new table. The source table I have looks something like this
AcctNum Social Number Name
0000111 555555555 David
0000122 555555555 David
0000123 555555555 David
0009899 333333333 Rose
0009896 333333333 Rose

and so forth for about 30,000 Accounts

I want to create a user file that looks like this
Social Nubmer Name Acct 1 Acct 2 Acct3 . . . .
555555555 David 111 122 123
333333333 Rose 9899 9896


Any ideas you guys can throw at me to help?

X002548
Not Just a Number

15586 Posts

Posted - 2005-08-17 : 11:20:16
Tell us what this gives you:

SELECT MAX(NUM_ACCOUNTS) FROM (
SELECT [Social Number], COUNT(*) AS NUM_ACCOUNTS FROM TABLE GROUP BY [Social Number]) AS XXX

This will tell you the max number of Account columns you'll need.

But why do this?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

Dang1337
Starting Member

3 Posts

Posted - 2005-08-17 : 12:12:59
I must have screwed up because it returned 2269, that is not right.

I'm trying to create a user based file that I'm going to import into a new system.
Go to Top of Page

Dang1337
Starting Member

3 Posts

Posted - 2005-08-17 : 12:28:41
Well, I got it right this time, and it looks like one user has 189 accounts, but i think I'd like to set a limit to 16 accounts. Anything above that they can call us and we'll manually add.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-18 : 01:07:02
Refer this also
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -