Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2002
    Location
    India
    Posts
    38

    Unanswered: adding dummy column in Sql Query

    Hi for all

    How to Add a Dummy column in my Sqlquery like Serial Numbers
    for example my query is
    Select OrderNo,OrderDate,OrderValue,DummyColumn as Slno from OrderTable Where OrderValue>4000

    ( DummyColumn this column was not in Table )

    so i want the result like

    Code:
       OrderNo   OrderDate    OrderValue    Slno
      -------------------------------------------------
       Rd001    10/25/2001     $5000         1
       Rd105    12/15/2002     $5657         2
       Rd441    10/15/2001     $8000         3
       Rd543    05/22/2002     $9040         4
       Rd333    09/05/2002     $5170         5
       Rd662    11/25/2002     $9556         6
    How to Get this result. Is it possible with out using StoredProcedures and Temp Tables.

    Please Give some sugessions.
    -- Prasad --

  2. #2
    Join Date
    Dec 2001
    Location
    chennai
    Posts
    21

    Dummy Column values

    hii
    please try this code in the northwind database, to get an idea

    declare @cmp varchar(100)
    declare @dc int
    set @dc = 0
    declare cur_sor cursor for select companyname from customers
    set @dc = @dc + 1
    open cur_sor
    fetch next from cur_sor into @cmp
    while @@fetch_status = 0
    begin
    select @dc as dummycolmn,@cmp as company
    fetch next from cur_sor into @cmp
    set @dc = @dc + 1
    end

    close cur_sor
    deallocate cur_sor

    regards
    ramki
    K.Ramakrishnan
    Chennai

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •