selecting a rowcount where it doesn't exist.

  • I want to do a select that will pull all four rows in a table of two columns (a and b) but tagged on the end is a rowcount. For example:

    select * from table:

    a b

    ---- -----

    ca cal

    wa was

    fl flo

    or ore

    Desired select returns:

    a b xcount

    ---- ----- -------

    ca cal 1

    wa was 2

    fl flo 3

    or ore 4

    without cursors or temp tables does anyone know how to do this?

  • Unfortunately this is not handled any direct way in SQL at this point.

    Like you said, cursor and temp tables work or add an IDENTITY column to the table. Or add an INT column and populate thru cursor and keep in sync are your generally accept ways.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply