General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Creating cursor with 3 fields from source table
Environment versions
Network:
Windows 2003 Server
Still learning SQL so after a few google searches giving no good results, I figured I would bug the experts. I am trying to get a list of all the unique salesreps (and their names) used in an order into a cursor. The problem is the reps are in three seperate fields on the table: salesrep1, salesrep2, and salesrep3. I am not sure if I need to use three seperate queries and do some sort of combining or if I can do it all in a 1 select statement. The statement below works great for one of the reps. Any help would be appreciated.
SELECT distinct invpost.salesrep1 as salesrep,ALLTRIM(salesrep.fname) + ' ' + ALLTRIM(salesrep.lname) as repname FROM invpost,salesrep ;
INTO CURSOR curRep WHERE invpost.salesrep1 = salesrep.salesrep AND !EMPTY(invpost.salesrep1) ORDER BY invpost.salesrep1
Thank you.
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only