If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to get data without including it in distinct select

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-13-08, 08:56
dakiar dakiar is offline
Registered User
 
Join Date: Mar 2008
Posts: 4
How to get data without including it in distinct select

I want to get some data, from 2 fields, but I don't want to select distinctly by them

In my tables I have

Table 1:
A B TIME

Table 2:
A B C D E TIME


my select is

select distinct a, max(2.TIME) from 1 , 2, where 1.a = 2.a and 1.TIME > "2008" GROUP by a

The problem I have is I want to get information about 2.b and 2.c from the fields in this select? is there anyway to do it??? thank you.

Dakiar
Reply With Quote
  #2 (permalink)  
Old 03-13-08, 11:36
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You are going to have to be more specific. Give some examples of the raw data and what you want to see in the result set.

Andy
Reply With Quote
  #3 (permalink)  
Old 03-14-08, 06:17
dakiar dakiar is offline
Registered User
 
Join Date: Mar 2008
Posts: 4
Hmm, it was that hard to understand?? I found out how to do it anyway:

select a, b, c from 2, (select distinct a, max(2.TIME) as MAX from 1 , 2, where 1.a = 2.a and 1.TIME > "2008" GROUP by a) as X where X.a = a AND X.MAX = TIME

Last edited by dakiar; 03-14-08 at 10:13.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On