Jumat, 21 September 2012

[MS_AccessPros] SQL, pulling specific rows from a table

 

I have a table that contains a list of financial institutions. Some of the institutions have more than 1 row due to information change.

BkID BkName NewDate OldDate
BK217 BANK NORTHEAST 20000331 19800331
BK217 BANK NORTHEAST 20041231 19840123
BK217 BANK NORTHEAST 20080630 19980924
BK217 BANK NORTHEAST 20120531 20000531
HK260 HARBOR BANKING COMPANY 20100331 19691231
BB510 BAYBANK and TRUST 20110425 19960202
NT190 NORFOLK TRUST 20120102 19960202
BT300 BAYSIDE TRUST COMPANY 20090202 19960202
BT500 BELKNAP BANK & TRUST 20080520 19880520
BT500 BELKNAP BANK & TRUST 20100618 19990618
BD602 BOSTON DEPOSIT COMPANY 20080607 19940407
NB310 NORTH BRISTOL BK & TR 20120310 19880310

My task is to pull out the institutions that have only 1 occurrence (exclude the repeated institutions), and include only the rows that have NewDate Between 20100101 and 20120603.

How do I achieve this kind of task? Use Sub queries?

This is what I tried, but I think this is not a correct way ...

SELECT BkID, BkName, NewDate, OldDate
FROM tblInstitution
WHERE Bk ID Not In (Bk217, BT500) And NewDate Between 20100101 And 2012630

Phucon

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar