Click here to Skip to main content
15,920,053 members
Home / Discussions / Database
   

Database

 
GeneralRe: SqlDataReader : I need to assign retrieved value to C++ variable Pin
Doug16-Oct-02 12:47
Doug16-Oct-02 12:47 
Generalmsado15.dll Pin
stevenson11-Oct-02 20:11
stevenson11-Oct-02 20:11 
GeneralRe: msado15.dll Pin
Michael P Butler12-Oct-02 1:55
Michael P Butler12-Oct-02 1:55 
GeneralQuestion about Transact SQL Pin
tongc11-Oct-02 6:38
tongc11-Oct-02 6:38 
GeneralRe: Question about Transact SQL Pin
Richard Deeming11-Oct-02 7:10
mveRichard Deeming11-Oct-02 7:10 
GeneralRe: Question about Transact SQL Pin
tongc11-Oct-02 13:48
tongc11-Oct-02 13:48 
GeneralRe: Question about Transact SQL Pin
Richard Deeming13-Oct-02 22:47
mveRichard Deeming13-Oct-02 22:47 
GeneralSQL Suggestions. Pin
Chris Meech11-Oct-02 4:24
Chris Meech11-Oct-02 4:24 
I have a view that joins a table back on itself like the following SQL
select  pm.portfolio_code master_code
       ,pp.portfolio_code part_code
from  portfolio pm
     ,portfolio pp
where pm.master_account_indicator = 1
  and pp.master_account = pm.portfolio_code
order by pm.portfolio_code, pp.portfolio_code

This produces some results like this
MASTER_CODE  PART_CODE
----------- ----------
         17          7
         17         12
         17         14
        227        226
        286        246
        286        287
        293         45
        293        440


Could someone suggest what has to be added so that a third colum gives me an incremented count of the master_code column. The result should be like this
MASTER_CODE  PART_CODE INC_COUNT
----------- ---------- ---------
         17          7         1
         17         12         2
         17         14         3
        227        226         1
        286        246         1
        286        287         2
        293         45         1
        293        440         2


I know how I can provide the data in some C++ code that will process the rows returned from the view, but I would really like to have the SQL do it for me.

Thanks for any suggestions.

Chris Meech
GeneralRe: SQL Suggestions. Pin
Jon Hulatt11-Oct-02 5:52
Jon Hulatt11-Oct-02 5:52 
GeneralRe: SQL Suggestions. Pin
Richard Deeming11-Oct-02 7:23
mveRichard Deeming11-Oct-02 7:23 
GeneralRe: SQL Suggestions. Pin
Chris Meech15-Oct-02 3:36
Chris Meech15-Oct-02 3:36 
GeneralFast SELECT Count Pin
Luca Leonardo Scorcia11-Oct-02 3:12
professionalLuca Leonardo Scorcia11-Oct-02 3:12 
GeneralRe: Fast SELECT Count Pin
Jon Hulatt11-Oct-02 3:42
Jon Hulatt11-Oct-02 3:42 
GeneralRe: Fast SELECT Count Pin
Daniel Turini11-Oct-02 3:52
Daniel Turini11-Oct-02 3:52 
GeneralRe: Fast SELECT Count Pin
Jon Hulatt11-Oct-02 4:23
Jon Hulatt11-Oct-02 4:23 
GeneralRe: Fast SELECT Count Pin
Luca Leonardo Scorcia11-Oct-02 6:55
professionalLuca Leonardo Scorcia11-Oct-02 6:55 
GeneralRe: Fast SELECT Count Pin
Daniel Turini14-Oct-02 0:55
Daniel Turini14-Oct-02 0:55 
QuestionOnly 255 char? Pin
Rickard Andersson2010-Oct-02 21:30
Rickard Andersson2010-Oct-02 21:30 
AnswerRe: Only 255 char? Pin
Mazdak10-Oct-02 22:01
Mazdak10-Oct-02 22:01 
GeneralRe: Only 255 char? Pin
Rickard Andersson2010-Oct-02 22:40
Rickard Andersson2010-Oct-02 22:40 
GeneralRe: Only 255 char? Pin
Nick Parker11-Oct-02 1:31
protectorNick Parker11-Oct-02 1:31 
GeneralRe: Only 255 char? Pin
Rickard Andersson2011-Oct-02 2:05
Rickard Andersson2011-Oct-02 2:05 
GeneralCascading delete in a self-joined table Pin
Wjousts10-Oct-02 10:14
Wjousts10-Oct-02 10:14 
GeneralRe: Cascading delete in a self-joined table Pin
Daniel Turini10-Oct-02 10:45
Daniel Turini10-Oct-02 10:45 
GeneralRe: Cascading delete in a self-joined table Pin
Wjousts11-Oct-02 3:16
Wjousts11-Oct-02 3:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.