Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / August 2006

Tip: Looking for answers? Try searching our database.

Nested selects

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mykas_Robi - 01 Aug 2006 18:21 GMT
Hello, I need to query a table to find unique values such that given the
below table,

name     claimant   loss date   close date   report date   name2    amt paid
vermal    ashford      010105    020506         020505     vermal     $10000
vermal    ashford      040105    030406         022805     kinsey      $50000
vermal    ashford      042505                        032805                  
 
vermal    douglas      010299                       021806     vermal      
$1000
vermal    douglas      010299    040505         021606     lycosa       $5000
vermal    robbie        030403                       040404    

I would like the results to be

name     claimant   loss date   close date   report date   name2    amt paid
vermal    ashford      010105   020506        020505       vermal     $10000
vermal    douglas      010299                       021806     vermal      
$1000
vermal    robbie        030403                       040404    

I am able to extract with select distinct but I can't extract the respective
columns; i might get any of the loss dates and I only want his row of data.

this is what I have; I get a name and claimant right but the rest may or may
not be their data
SELECT DISTINCT [rolo 4].[clmnt NAME1], First([rolo 4].LOSS_DT) AS
FirstOfLOSS_DT, First([rolo 4].REPORT_DT) AS FirstOfREPORT_DT, First([rolo
4].[close_dt]) as Firstclosedt,  Max([rolo 4].STATUS) AS Maxstatus, Max([rolo
4].APPORT) AS MaxOfAPPORT, Max([rolo 4].[Def Status]) AS MaxOfdefstatus,
First([rolo 4].Description) AS firstdes
FROM [rolo 4]
WHERE ((([rolo 4].[Ins LASTNAME])=[Enter Ins Last Name]) AND (([rolo
4].CCS)<>"1"))
GROUP BY [rolo 4].[clmnt NAME1];

Please advise on how best to do this
Michel Walsh - 01 Aug 2006 22:44 GMT
Hi,

What about

SELECT name, claimant, FIRST(lossDate), FIRST(closeDate), FIRST(reportDate),
FIRST(name2), FIRST(amtPaid)
FROM  [rolo 4]
GROUP BY name, claimant

Hoping it may help,
Vanderghast, Access MVP

> Hello, I need to query a table to find unique values such that given the
> below table,
[quoted text clipped - 43 lines]
>
> Please advise on how best to do this
Mykas_Robi - 03 Aug 2006 15:58 GMT
Thank you Michel for the quick response.  The query i need can't select
arbitrary values for loss date, close date, etc.  They must be the values for
the selected individual. I hope I have clarified this.  

> Hi,
>
[quoted text clipped - 55 lines]
> >
> > Please advise on how best to do this
Michel Walsh - 03 Aug 2006 23:04 GMT
Hi,

Using FIRST (or LAST) on each field not in the GROUP BY clause will do
exactly that:  all the values will come from the SAME record.

Hoping it may help,
Vanderghast, Access MVP

> Thank you Michel for the quick response.  The query i need can't select
> arbitrary values for loss date, close date, etc.  They must be the values
[quoted text clipped - 65 lines]
>> >
>> > Please advise on how best to do this
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.