Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Combine two queries having 'distinct' & 'max' functions

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
banand

New User


Joined: 05 Jun 2007
Posts: 28
Location: Mumbai

PostPosted: Tue Oct 07, 2008 4:29 pm    Post subject: Combine two queries having 'distinct' & 'max' functions
Reply with quote

Hi

I want to combine two queries in to one query.Please suggest me whether it is possible. if so how? below are the two queries.
==========================================
select VALUE(MAX(CLASS_ROLL_NO),0),VALUE(MAX(CLASS_TAB_NO),0)
INTO :CLACE.ROLL_NO,
:CLACE.TAB_NO
FROM CLASS_TABLE
WHERE CLASS_CD=:CLACE.CLASS_CD
==========================================
SELECT DISTINCT(CLASS_MEM)
INTO :CLACE.CLASS_MEM
FROM CLASS_TABLE
WHERE CLASS_CD=:CLACE.CLASS_CD
===========================================
Back to top
View user's profile Send private message

anandinmainframe

Active User


Joined: 31 May 2007
Posts: 171
Location: India

PostPosted: Wed Oct 08, 2008 9:06 am    Post subject: Reply to: Combine two queries having 'distinct' & 'max'
Reply with quote

Hi Bala,
select VALUE(MAX(CLASS_ROLL_NO),0),VALUE(MAX(CLASS_TAB_NO),0),
DISTINCT(CLASS_MEM)
INTO :CLACE.ROLL_NO,
:CLACE.TAB_NO,
:CLACE.CLASS_MEM
FROM CLASS_TABLE
WHERE CLASS_CD=:CLACE.CLASS_CD

i hope it will work
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Can we combine the rows with same key... V S Amarendra Reddy DB2 14 Fri Dec 01, 2017 10:29 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm
No new posts Need help with below queries ashek15 DB2 3 Thu Mar 23, 2017 1:38 am
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us