1 / 16

Some other query issues:

Some other query issues: To sort in a query place either “ascending” or “descending” in the sort line of the query in the appropriate field. The Like condition: Wildcards

eugene
Télécharger la présentation

Some other query issues:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Some other query issues: To sort in a query place either “ascending” or “descending” in the sort line of the query in the appropriate field.

  2. The Like condition: Wildcards The Like condition allows you to create a Query condition which matches certain patterns. There are 3 wildcard characters. * Arbitrary number of characters ? A single character # A single numeric digit 1) Given a list of names: Which names has an a in the second character? Like “?a*” matches Tammy Jane but not John 2) Given a list of names: Which names starts with an m? Like “m*” matches Moses , Manny, Mary, Max

  3. Given a list of names: Which name has a “k” in it? Like “*k*” matches Lucky Knut Match a name: Like "Smith“ Match a name beginning with “Sm”: Like "Sm*“ Match a string with a letter followed by 3 digits: Like “?###”

  4. Do you need to isolate records where a field has not been filled in? Use: is null in the criteria line To use dates put # around the date: >#26/11/2009# and <#31/12/2009# The between operator (it is inclusive) BETWEEN #6/15/2009# AND #8/15/2009# BETWEEN 10.0 AND 15.0

  5. Grouping Queries Suppose you have a table as below with names and value . You wish to make a query which gives the sum( or AVG or COUNT) of the values.

  6. Create a query with the two fields on the table. • Select the two fields. • Pick the design menu in the menu bar. • Change the query type to a grouping query by clicking the Sigma symbol in the tool bar. You will notice that a “total line” appears below and each field has “group by” in it. • Replace the “group by” in the field you wish to sum by “sum” (or if you wish by AVG or COUNT) • Save the query and run it.

  7. So following the steps. If we start with the table: The query looks like:

  8. The result is:

  9. Make Table Queries “Select Queries” or the regular queries are self contained objects but the result of a query looks like a table. If you wish to make the results of a query into a table we use a : Make table Query” This type of query is made from a “select” query. So we need to create a select query on some table in the usual way.

  10. Design your select query and run it to make sure it has the desired look. • Open your query in design view. • Click on Make Table and name the table in the dialogue box that appears. 4.Run the query: BUT IT STILL MAY NOT WORK SO SEE NEXT SLIDE

  11. If the new table does not appear, You may see a warning: Security warning: certain content in this database has been disabled. Click on the options box beside it and click on the “enable this content” and then run the query. You will then see the result of the query in your new named table.

  12. Importing and exporting in Access Access allows you to bring in data from other formats and export data to other formats. e.g. Import a text file into an Access table e.g export an access table to a spreadsheet.

  13. e.g. Importing a text file. Example comma delimited text file. Data is delimited by commas. Problem if you have commas as part of the text. A0001,Banks,Rob,555-2232,23 Elm St.,Ottawa,ON,K3O 4J2 A0003,Dover,Ben,378-2321,565 Oak Ave.,Nepean,ON,H6J 9J9 A4339,Dup,Stan,923-4348,232 Lois Lane,Toronto,ON,H3J 3J3 B0023,Jass,Hugh,789-0988,67 Pine Cres.,Montreal,QU,J8J 0L9 B0024,Bird,Earl E.,890-1232,809 Birch Ave.,Toronto,ON,K9D 8E8 C0012,Pull,Sam,892-3323,102 Lois Lane,Toronto,ON,K9D 8E8 C0054,Class,Jim,892-5673,63 Moodie Drive,Nepean,ON,K1D 3J4

  14. Example: comma and quote delimited text file. Data is delimited by commas and quotes. "A0001","Banks","Rob","555-2232","23 Elm St.","Ottawa","ON","K3O 4J2" "A0003","Dover","Ben","378-2321","565 Oak Ave.","Nepean","ON","H6J 9J9" "A4339","Dup","Stan","923-4348","232 Lois Lane","Toronto","ON","H3J 3J3" "B0023","Jass","Hugh","789-0988","67 Pine Cres.","Montreal","QU","J8J 0L9" "B0024","Bird","Earl E.","890-1232","809 Birch Ave.","Toronto","ON","K9D 8E8" "C0012","Pull","Sam","892-3323","102 Lois Lane","Toronto","ON","K9D 8E8" "C0054","Class","Jim","892-5673","63 Moodie Drive","Nepean","ON","K1D 3J4"

  15. To import: In the external data tab Under the “import” group import “text file” and follow the wizard. You will have to name the fields and specify the types but the wizard will do pretty well.

  16. To export data: For example turning an Access table into an excel spreadsheet. In the external data tab Under the “export” group export “excel” and follow the wizard. You have to specify the name and destination and you will probably have to adjust the heading labels in the resulting spreadsheet.

More Related