IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

how to compare between columns


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
naanu

New User


Joined: 02 Jun 2005
Posts: 3

PostPosted: Tue Jun 07, 2005 9:21 am
Reply with quote

hi guys ,

suppose i have one table contain marks in all subjects and his/her name.

if i gave his/her name the result of the query should show the highest marks obtained by her/his in any subject

could you plz help me to write the query


Regads
naaanu
Back to top
View user's profile Send private message
Pushpak

New User


Joined: 06 May 2005
Posts: 18

PostPosted: Tue Jun 07, 2005 11:43 am
Reply with quote

Hi,

Could you please try following query?

SELECT NAME,SUBJECT,MARKS
FROM XYZ
WHERE NAME = 'A' AND
MARKS IN (
SELECT MAX(MARKS)
FROM XYZ
WHERE NAME = 'A'
);

Pushpak.
Back to top
View user's profile Send private message
naanu

New User


Joined: 02 Jun 2005
Posts: 3

PostPosted: Tue Jun 07, 2005 12:37 pm
Reply with quote

Pushpak wrote:
Hi,

Could you please try following query?

SELECT NAME,SUBJECT,MARKS
FROM XYZ
WHERE NAME = 'A' AND
MARKS IN (
SELECT MAX(MARKS)
FROM XYZ
WHERE NAME = 'A'
);

Pushpak.




sorry i think you have not understand the problem correctly

table has name column and subject column like


name mat sci sol lan lan2


my prob is if i gave the name i should get sub on which he got max marks
Back to top
View user's profile Send private message
Pushpak

New User


Joined: 06 May 2005
Posts: 18

PostPosted: Tue Jun 07, 2005 1:00 pm
Reply with quote

Hi,

Could you plz provide more detail ? Like Columns, Data & expected result with value.

Pushpak.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Remote Unload of CLOB Columns DB2 6
No new posts Increase the number of columns in the... IBM Tools 3
No new posts Compare two files with a key and writ... SYNCSORT 3
No new posts DB2 Views with Multiple SQL & Col... DB2 8
Search our Forums:

Back to Top