PDA

View Full Version : Query to run report by group



Klartigue
11-17-2011, 10:48 AM
In access, i have account numbers in field 1(labeled Account Number) and I have a field labeled Composite. In the composite field, for each record it can either say "municomp", "restricted", "tbndcomp","taxcash" , "cashcomp", "sdmuni" or "shrtdura". I would like to create a query that can be run to select a certain category for the composite and pull up all the accounts in that category.

Thanks for the help!

mohanvijay
11-17-2011, 08:13 PM
for get all category




select [Account Number],[Composite] from your_table group by
[Composite],[Account Number]



for pariticular category



select [Account Number] from your_table where [composite]='municomp'



if pariticular category more than one




select [Account Number] from your_table where [composite] in ('municomp','restricted')

Klartigue
11-21-2011, 01:30 PM
select [Account Number] from your_table where [composite]='municomp'


This code works great because it pulls all the account numbers that are in the municomp composite. The account numbers are the primary keys for each record. I would like to pull the other fields along with the account number. Each record has a field for "Account Name" "Secondary Description" "Investments" and "Quality".

How do i get those fields to show up for each record pulled?

Klartigue
11-21-2011, 02:23 PM
SELECT Accounts.[Account Number], Accounts.[Account Name], Accounts.[Secondary Description], Accounts.[Investments], Accounts.[Quality], Accounts.[Taxable], Accounts.[Composite], Accounts.[Primary Description]
FROM Accounts
WHERE (((Accounts.composite) In ('municomp','restricted')));


Nevermind, i figured it out!