Top 10 Subquery in Access SQL -


select top 10 [final_for_db].[indemnity_paid]/[final_for_db].[claim_count] indemnity_cost,  final_for_db.claimant_name,  final_for_db.account_name,  final_for_db.claim_id,  final_for_db.file_date,  final_for_db.resolution_date,  final_for_db.claim_status,  final_for_db.state_filed, final_for_db.expense_amount,  final_for_db.claim_count,  final_for_db.indemnity_paid [total indemnity] final_for_db (((final_for_db.account_name)="exxon")) order [final_for_db].[indemnity_paid]/[final_for_db].[claim_count] desc; 

this give me top 10 entries exxon wondering if there way top 10 entries each account name biggest indemnity cost lowest. believe there need subquery. appreciate on this. thanks

other rdbms's support rank() , row_number() functions. unfortunately, access not (to knowledge). should close want. not handle duplicates (two customers same indemnity cost same rank, possibly leaving top 11 or so).

select *  (     select *         , (             select count(*)              final_for_db tbl2             (tbl1.indemnity_paid/tbl1.claim_count) < (tbl2.indemnity_paid/tbl2.claim_count)                 , tbl1.account_name= tbl2.account_name         ) + 1 rank final_for_db tbl1 ) x x.rank < 10 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -