Re: Sorting Problem

From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 06/30/04


Date: Wed, 30 Jun 2004 16:05:53 +0530

hi nomi,

>>The result set aways has a different order. The problem occurs in the
insert into statement,
it does not insert the data in sorted order inspite of order by clause.
i Have created STable with the following script.<<

Remember that table is an unordered set of rows. physical ordering of rows
does not gurantee the retrieval order of
the rows in SELECT statement. Only way to get ordered result is by using
"order by" clause statement in the SELECT
statement.

So to get required resultset in specific order make use of "order by"
clause.

if you fire following query, then resulset will be sorted on the basis of
COUNTER column that is what i can see in the resulset you've posted.

select counter,
   CCode,
   field1,
   field2
   FROM STable
   WHERE sid=@sid
   and stypeid=6
order by counter

-- 
Vishal Parkar
vgparkar@yahoo.co.in | vgparkar@hotmail.com


Relevant Pages

  • Re: Sorting Problem
    ... > data in sorted order inspite of>order by clause. ... Only by running SELECT clause and specify ORDER BY clause you can ... >> database that i have has same collation settings. ...
    (microsoft.public.sqlserver.programming)
  • Re: working with multiple input files
    ... Your BEGIN clause is executing, ... If you are calling this from a batch file, the script will exit. ... You should process the second file within your begin clause as well, ...
    (comp.lang.awk)
  • Can Visio generate a Valid Oracle DDL Statement ?
    ... I am designing DB model for Oracle 9i using Visio for enterprise architect, ... when I generate the script, ... I have to add manually this additional clause: ... LOGGING TABLESPACE IDX01; ...
    (microsoft.public.visio.developer)
  • Re: How set a
    ... Amartya wrote: ... i have a problem with "where clause" event, ... to update a database. ... I tried this script but nothing ...
    (comp.soft-sys.matlab)
  • [Info-ingres] Wrong results returned from outer join
    ... " Outer joins specified in the from clause are not the same as joins ... while the where clause specifies restrictions to be applied to the sources ... Still the script returns all 2 rows. ... ON COMMIT PRESERVE ROWS WITH NORECOVERY ...
    (comp.databases.ingres)