Click here to Skip to main content
16,004,686 members
Home / Discussions / Database
   

Database

 
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 
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 
Thanks for the suggestions. This morning, I finally got the view to do what I wanted. With the knowledge that the portfolio_code column of the portfolio table is a unique identifier for each row, I got the following SQL to run and do exactly what I was looking for.
select  pm.portfolio_code master_code
       ,pp.portfolio_code part_code
       ,( select count(c.portfolio_code) from portfolio c
          where c.portfolio_code <= pp.portfolio_code
            and c.master_account = pm.portfolio_code
        ) inc_count
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


Essentially, as each row is returned, another query runs and returns the count of portfolio_code that is less than or equal to the value in the row being returned.

Chris Meech
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 
GeneralBulk Insert (ADO/Access2000) Pin
ssirisha10-Oct-02 9:56
ssirisha10-Oct-02 9:56 
GeneralRe: Bulk Insert (ADO/Access2000) Pin
Mazdak10-Oct-02 22:02
Mazdak10-Oct-02 22:02 
GeneralRe: Bulk Insert (ADO/Access2000) Pin
ssirisha11-Oct-02 2:01
ssirisha11-Oct-02 2:01 

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.