Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 pls help

Author  Topic 

rammohan
Posting Yak Master

212 Posts

Posted - 2009-11-20 : 04:33:13
hi i have a table data like this

Name Subject Marks Result

Steve Maths 50 P
Steve Scince 50 P
Steve Social 35 F
John Maths 50 P
John Scince 50 P
John Social 35 F

now i need to write a query to display result like this:


Name Subject Marks Result

Steve Maths 50 P
Scince 50 P
Social 35 F
John Maths 50 P
Scince 50 P
Social 35 F

is it possible to write a query to get result like this?


One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-11-20 : 04:38:22
you should do this in your front end application not in TSQL


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-20 : 05:03:35
quote:
Originally posted by rammohan

hi i have a table data like this

Name Subject Marks Result

Steve Maths 50 P
Steve Scince 50 P
Steve Social 35 F
John Maths 50 P
John Scince 50 P
John Social 35 F

now i need to write a query to display result like this:


Name Subject Marks Result

Steve Maths 50 P
Scince 50 P
Social 35 F
John Maths 50 P
Scince 50 P
Social 35 F

is it possible to write a query to get result like this?


One can never consent to creep,when one feels an impulse to soar
RAMMOHAN




Put the code tags [code ]your code[/code ] (remove space)
This is called "suppress if duplicated"
Where do you want to show data?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rammohan
Posting Yak Master

212 Posts

Posted - 2009-11-20 : 05:21:47
i am planning to fill this query result to dataset in .net, so i want to get data like this from query


One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

Go to Top of Page

kbhere
Yak Posting Veteran

58 Posts

Posted - 2009-11-20 : 05:56:53
Using cursor we can do this..
If your application can use cursor, this task can be easily done..


Balaji.K
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-20 : 07:28:13
quote:
Originally posted by rammohan

i am planning to fill this query result to dataset in .net, so i want to get data like this from query


One can never consent to creep,when one feels an impulse to soar
RAMMOHAN




Do you want to show them in grid?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rammohan
Posting Yak Master

212 Posts

Posted - 2009-11-20 : 08:22:07
hi madhvinan,

i need to export this dataset to excel. it is a console application

One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-30 : 04:56:56
quote:
Originally posted by rammohan

hi madhvinan,

i need to export this dataset to excel. it is a console application

One can never consent to creep,when one feels an impulse to soar
RAMMOHAN




When you export data to EXCEL from grid, suppress the duplicated values

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -