-
srno
i want to display the srno in my output query,how to do it
eg;if i say "select name,code from emp"
i want some thing like this
no name code
1 abc a01
2 xyz a02
how to do like this,i wish to do this in sql query only ,no proc
-
--if you do not have any unique column then
create table x124 (code varchar(10), name varchar(100))
insert into x124 select 'a01','abc'
insert into x124 select 'a02','xyz'
insert into x124 select 'a02','333'
select no=identity(int,1,1),code,name into #x from x124
select * from #x
drop table #x
-
--If you have one unique column atleast then
create table x1245 (code varchar(10), name varchar(100))
insert into x1245 select 'a01','abc'
insert into x1245 select 'a02','xyz'
insert into x1245 select 'a03','333'
SELECT Code,Name,(SELECT count(Code) as no FROM x1245 AS x
WHERE y.code >= x.code) AS no FROM x1245 AS y
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|