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 2000 Forums
 Transact-SQL (2000)
 Select distinct

Author  Topic 

u2p_inst
Yak Posting Veteran

78 Posts

Posted - 2002-12-20 : 03:57:33
ID_A ID_B ID_C Date Desc
-------------------------------------------------------------------
1 103115 1 2002-07-04 PHINISI DANA KAS
1 103115 1 2002-07-25 PHINISI DANA KAS
1 103115 1 2002-07-25 PHINISI DANA KAS
1 103115 1 2002-11-22 PHINISI DANA KAS
1 103115 1 2002-11-28 PHINISI DANA KAS
1 103115 1 2002-11-28 PHINISI DANA KAS
19 103115 1 2002-03-27 COMMONWEALTH DANA PREMIUM
19 103115 1 2002-04-25 COMMONWEALTH DANA PREMIUM
19 103115 1 2002-05-08 COMMONWEALTH DANA PREMIUM
19 103115 1 2002-05-13 COMMONWEALTH DANA PREMIUM
19 103115 1 2002-05-24 COMMONWEALTH DANA PREMIUM
20 103115 1 2002-07-25 SCHRODER DANA MANTAP PLUS
20 103115 1 2002-07-25 SCHRODER DANA MANTAP PLUS
20 103115 1 2002-07-26 SCHRODER DANA MANTAP PLUS
20 103115 1 2002-07-26 SCHRODER DANA MANTAP PLUS
23 103115 1 2002-11-12 ABN AMRO DANA KAS RUPIAH
23 103115 1 2002-11-12 ABN AMRO DANA KAS RUPIAH

how to make result like that but the ID_A is no duplicate


oh

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2002-12-20 : 04:08:53
quote:

ID_A ID_B ID_C Date Desc
-------------------------------------------------------------------
1 103115 1 2002-07-04 PHINISI DANA KAS
1 103115 1 2002-07-25 PHINISI DANA KAS
1 103115 1 2002-07-25 PHINISI DANA KAS
1 103115 1 2002-11-22 PHINISI DANA KAS
1 103115 1 2002-11-28 PHINISI DANA KAS
1 103115 1 2002-11-28 PHINISI DANA KAS
19 103115 1 2002-03-27 COMMONWEALTH DANA PREMIUM
19 103115 1 2002-04-25 COMMONWEALTH DANA PREMIUM
19 103115 1 2002-05-08 COMMONWEALTH DANA PREMIUM
19 103115 1 2002-05-13 COMMONWEALTH DANA PREMIUM
19 103115 1 2002-05-24 COMMONWEALTH DANA PREMIUM
20 103115 1 2002-07-25 SCHRODER DANA MANTAP PLUS
20 103115 1 2002-07-25 SCHRODER DANA MANTAP PLUS
20 103115 1 2002-07-26 SCHRODER DANA MANTAP PLUS
20 103115 1 2002-07-26 SCHRODER DANA MANTAP PLUS
23 103115 1 2002-11-12 ABN AMRO DANA KAS RUPIAH
23 103115 1 2002-11-12 ABN AMRO DANA KAS RUPIAH

how to make result like that but the ID_A is no duplicate


oh



Can you please elaborate more and post the query?


Expect the UnExpected
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2002-12-20 : 04:21:27
????
maybe

select *
from tbl
where Date = (select min Date from tbl t2 where t2.ID_A = tbl.ID_A)


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2002-12-20 : 09:29:06
Decide which of the dates, which appear to be the only fields that change, you want to return, if any. for example, do you want the lowest (MIN) or the highest (MAX) for each group?

Then you can say:

SELECT
ID_A, ID_B, ID_C, MIN(Date) as MinDate, Desc
FROM
Table
GROUP BY ID_A, ID_B, ID_C, Desc


take away fields from the GROUP BY and add MIN's or MAX's to the SELECT part as needed.

- Jeff
Go to Top of Page
   

- Advertisement -