Help Me Build Simple SQL Query!
Feb 11, 2006
(Dear Admin, don't be mad I posted this post elsewhere but had no luck with answers)
Please guys, I just forgot how to do this:
I have a table with primary key (id) and sort of secondary key (id1). Several rows can have same id1.
id id1
1 1
2 1
3 1
4 1
5 3
6 3
7 4
8 4
9 4
...
I need to count the id1 - how many different id1 values are there.
This doesn't work:
SELECT COUNT(id1) FROM table GROUP BY id1
this also doesn't work:
SELECT COUNT(id1) FROM table
As I recall, it was something about DISTINCT function or something like that...?
Please help, I'm sure it's totally simple, but I'm stuck.
View Replies
ADVERTISEMENT
Aug 28, 2007
I have some database with columns 'Number', 'Mfr Name' and 'Mfr Part Number'.
Number - internal catalogue item of a company.
Mfr Name - name of a manufacturer where from we purchase the item
Mfr Part Number - part number of a manufacturer where from we purchase the item
Each item may have one or more Mfr Name & Mfr Part Numbers.
----------------------------------------------------------------------
I need to build a following query:
Input gets part of Mfr Part Number and output is all Mfr Name & Mfr Part Number of match item.
View 6 Replies
View Related
Oct 7, 2005
How can I build a date in a query that is used for filtering purposes? The data is in the records in two fields - Month and Year. In our query we have an expression that builds a date - DateRange: [Month]/1/[Year] in order to qualify the record with the criteria Between FromDate and ThruDate. DateRange as it is shown here returns a date of 12/30/1899 for all records. DateRange: #[Month]/1/[Year]# is invalid syntax. DateRange: [Month] & "/" & 1 & "/" & [Year] is not recognized as a date.
View 4 Replies
View Related
Jul 5, 2006
Hi all, I have a field that stores software versions as text. The version numbers can be simple (4.0, 5.0) or unknown or more complicated (4.5.200512, etc). The user wants to be able view data in a pivotChart without seeing interim versions- so 4.5.200512 would not show up but its data would be counted as part of 4.5. Anybody know how I can do this?
thanx
View 1 Replies
View Related
Oct 26, 2006
Hi everybody,
Let's say that I've got the following tables:
- tblCustomers(IDCust,NameCust)
- tblEmployees(IDEmpl,NameEmpl)
- tblProjects(IDProj,IDCust,IDEmpl,Duration)
My query:
SELECT tblCustomers.NameCust, tblProjects.IDProj, tblProjects.Duration, tblEmployees.NameEmpl, Sum(tblProjects.Duration) AS SumOfDuration
FROM (tblProjects INNER JOIN tblEmployees ON tblProjects.IDEmpl = tblEmployees.IDEmpl) INNER JOIN tblCustomers ON tblProjects.IDCust = tblCustomers.IDCust
GROUP BY tblCustomers.NameCust, tblProjects.IDProj, tblProjects.Duration, tblEmployees.NameEmpl
ORDER BY tblCustomers.NameCust;
What I'd like get when running my query is:
NameCust ------ IDProj - Duration ----- NameEmpl ------- ?????????
CUST1 ---------- 1 ------ 3 ------------ EMPL3 ---------- 7
CUST1 ---------- 2 ----- 10 ------------ EMPL4 --------- 10
CUST1 ---------- 9 ------ 2 ------------ EMPL3 ---------- 7
CUST1 --------- 11 ------ 2 ------------ EMPL3 ---------- 7
CUST1 --------- 13 ------ 8 ------------ EMPL1 ---------- 9
CUST1 --------- 18 ------ 1 ------------ EMPL1 ---------- 9
CUST2 ---------- 3 ----- 20 ------------ EMPL1 --------- 20
CUST2 ---------- 4 ----- 12 ------------ EMPL3 --------- 17
CUST2 ---------- 5 ------ 3 ------------ EMPL2 ---------- 4
CUST2 --------- 10 ------ 5 ------------ EMPL3 --------- 17
CUST2 --------- 17 ------ 1 ------------ EMPL2 ---------- 4
CUST3 ---------- 6 ----- 25 ------------ EMPL4 --------- 27
CUST3 --------- 14 ------ 2 ------------ EMPL1 --------- 14
CUST3 --------- 15 ------ 2 ------------ EMPL4 --------- 27
CUST3 --------- 16 ----- 12 ------------ EMPL1 --------- 14
CUST3 --------- 19 ------ 2 ------------ EMPL2 ---------- 2
where ???????? (manually done) = the sum of the Employee duration for ONE Customer !!!
But what I get instead:
NameCust ------ IDProj - Duration ----- NameEmpl ------- SumOfDuration
CUST1 ---------- 1 ------ 3 ------------ EMPL3 ---------- 3
CUST1 ---------- 2 ----- 10 ------------ EMPL4 --------- 10
CUST1 ---------- 9 ------ 2 ------------ EMPL3 ---------- 2
CUST1 --------- 11 ------ 2 ------------ EMPL3 ---------- 2
CUST1 --------- 13 ------ 8 ------------ EMPL1 ---------- 8
CUST1 --------- 18 ------ 1 ------------ EMPL1 ---------- 1
CUST2 ---------- 3 ----- 20 ------------ EMPL1 --------- 20
CUST2 ---------- 4 ----- 12 ------------ EMPL3 --------- 12
CUST2 ---------- 5 ------ 3 ------------ EMPL2 ---------- 3
CUST2 --------- 10 ------ 5 ------------ EMPL3 ---------- 5
CUST2 --------- 17 ------ 1 ------------ EMPL2 ---------- 1
CUST3 ---------- 6 ----- 25 ------------ EMPL4 --------- 25
CUST3 --------- 14 ------ 2 ------------ EMPL1 ---------- 2
CUST3 --------- 15 ------ 2 ------------ EMPL4 ---------- 2
CUST3 --------- 16 ----- 12 ------------ EMPL1 --------- 12
CUST3 --------- 19 ------ 2 ------------ EMPL2 ---------- 2
Any suggestion to build this Query ??
Thanks in advance
View 3 Replies
View Related
Mar 21, 2006
select student from tbl_TableName where max(date_borrowed) <= dateadd("d",-730,Date())
group by student
??? How do I set this up? and do the max date_borrowed?
Thanks.
View 2 Replies
View Related
Feb 20, 2008
As example, I have a table with an Item number, introduction year and a number of historical and future Sales periods set per year, these sales columns are listed Y1990, Y1991, Y1992....... Y2015.
Based on each items introduction year, I want to list the first 5 years of sales.
I wanted to create a dimensional fieldname eg: FirstYear: "Y"&[introduction year] to get the value of that respective year. (I currently just get a text saying "Y1995", and not the content )
Any help is appreciated!:)
(Note: I can't transpose the data in the tables for other reason)
View 3 Replies
View Related
Jan 14, 2013
Currently, I use ACCESS to track reservations for various types of events. When I want to make nametags, I download the "attendee" query that I've already set up to EXCEL and then merge into a WORD document. Is there a way to set up in ACCESS so the labels can be printed straight from the database? I've tried, but I can't get the labels to space out properly (EX: 2 across and 6 down) even though I put the correct label # in there.
View 4 Replies
View Related
Sep 9, 2013
I'm making an accounts package.
I've made a graph of revenue by customer but due to the number of customers it's a bit hard to see the customer names.
So I would like to be able to select my own custom group of 5 customers to plot on the graph.
To do this I think I need a query that selects the 5 customers which is populated from 5 comboboxes on a new form that the user can select customer names from but I'm not sure of the VBA that links all this together.
View 2 Replies
View Related
Jul 1, 2014
I have a difficult problem (because of my own capabilities). I have a table (tblFoods) which includes a number of food with their analyzes. I have a second table (tblExclusiveFoods) which is connected with a third table (tblCustomers) with one-to-many relation. Namely, o tblCustomers is the "One" and tblExclusiveFoods is the "Many".
Into table tblExclusiveFoods there is a field that acts like a ComboBox and gets data from the tblFoods such as drop-down-menu. So, using the combo box i can select the foodID from tblFoods and then showing into exFood field which is a part of the tblExclusiveFoods fields. When i collect the foodID's from the tblFoods, i would like to to build a query which will exclude these foods from the tblFoods.
View 10 Replies
View Related
Jan 2, 2014
What query would I use to build a date in m/d/yyyy format using month, day and year values from another field?
View 2 Replies
View Related
Aug 8, 2006
How do I build a form which will pull only certain work orders from my table [Work Orders], filter it through a query, [Payroll] which gives me only those work orders which match a certain repID#, for only certain Invoice Dates, and and then display a talley of the total number of times a certain product appears in the field [ProductSold] on the query [Payroll]?
View 1 Replies
View Related
Feb 23, 2007
I can't find anything in the archive relating to this...
Can someone tell me how to enable the "Build" feature in the Visual Basic screen in 2003, please?
I recently upgraded from 97 and can only find the "Build" feature in Query Design.
In 97 it was available by right clicking the screen and selecting "Build". I have no such option when right clicking in 2003.
Thanks
View 5 Replies
View Related
Dec 4, 2006
Can anybody help me build the last table in my database? I have taught myself Access – and can usually get by with a little help from this forum. I have been trying for days to try and solve this !!!
The database is designed to manage feedback questionnaires from attendees of training courses.
I have attached the relationship diagram.
- A course may run for several days. The details of the course are held in the table ‘Courses’. During a course, attendees may be asked to fill in several Questionnaires
- An Attendee is a Person that attends a Course. Attendees are held in the table ‘Attendees’ and their details are held in the table ‘Person’.
- There is a ‘Library’ of questions that sit in the table ‘Questions’
- The questions can be assembled into “Standard Questionnaires”. These sit in the table called “Questdesign” which is a junction table. Assembling a Standard Questionnaire involves using a form to pick questions and give them an order (Qnumber). I HAVE DONE THIS.
- A specific “Questionnaire” is a “Standard Questionnaire” that is used on a specific course. The list of Questionnaires is held in the table “Questionnaire”
- Scoresheet is the junction table between Attendee and Questionnaire (an Attendee on a course may fill in several Questionnaires and a Questionnaire may be filled in by lots of Attendees.)
I now need a table (Scores) in which to put all the scores to the questions (in other words, the scores of the questions on the Questionnaires that are completed by the Attendees on a Course.)
At the end of the day I am aiming to have a form in which:
The Attendee number is entered and all the person’s details are filled in automatically) – I HAVE DONE THIS
The Questionnaire number is entered and all the course details are filled in automatically – I HAVE DONE THIS
A Scoresheet ID is filled in (Autonumber) - I HAVE DONE THIS
A subform appears which shows the right set of questions and question numbers for the appropriate Questionnaire – with a blank column so that the user can fill in the scores which get stored in the Scores Table. - I CAN'T DO THIS !!!
I cannot work out where to link my Scores table and how to build a query that drives the correct behaviour of the subform
I hope I have explained this clearly. I would be so grateful for any help. This Forum is fabulous.
Many thanks
NoVoiceLeft
View 6 Replies
View Related
May 26, 2006
I have attacked quite a few guides ( Dummies & Absolute Beginners ) on how to build a database of my gardening clients, but have run into a problem that they can't seem to resolve. Is there anyone out there who can help me with "referential integrity" and trying to link relationships between the various tables I have created.
View 3 Replies
View Related
Jan 8, 2007
Hello All
Does anyone know how you might build sliding bar displays as an input device for scores into an Access database? I am building an application that could really use something like this.
Here is an example. First go to the 'Chelsea tab', slide the bars, submit the results, and see the results on the "Results" tab
http://news.bbc.co.uk/sport1/hi/football/teams/c/chelsea/6173703.stm
Very impressive
NoVoice
View 6 Replies
View Related
Apr 22, 2006
hi
hi
i have sql query in a string
strQuery="...."
how to create temporary table with the result of this query?
thanks
View 1 Replies
View Related
Feb 9, 2006
Hi all.
I have been given a simple task, but i have no idea how to do it! I need a form to do the following:
User types in a reference, for example TEST1
We have a standard link along the lines of http://www.testtesttest.com/blaablaa/
We need access to append the "TEST/1" (or whatever the user has entered) to the end of the link, so the result would be:
http://www.testtesttest.com/blaablaa/TEST1
I would be extremely greateful of someone could let me know the best way of getting this done.
Kind Regards
Darren
View 1 Replies
View Related
Dec 25, 2006
Hi
I 'm new at this Forum and also I'm new programmer in Access.
I 'm trying to answer project called (Cerulean Bee) ,which is attachment down
I do the table and forms but I don't know how I can let them as it the question (Artwork Order-Employee Work Log-Print Order-Project Cost Analysis).
Her my file http://www.megaupload.com/?d=XP34TRO3
Please help me to find ant error I do , and to get best answer for my question.
I'm realy need your help
Thank you all
View 2 Replies
View Related
May 11, 2005
Hi there,
I have a really simple question.
I have a field in a table that contains comments (text format). I want to run a query where I can get only the records that contain the word "high" in the comments. There may be some typos so I would like records returned that also contain something like "high". High is not the only word in the comments.
Does this make sense?
Thanks,
Row
View 4 Replies
View Related
Jul 26, 2005
Hi guys, wondering if you could help me, I can't seem to get this right..
I have two tables in question:
Items: StyleTypes:
------ ------------
ItemID ItemType
ItemType StyleType
Style
Lots of Attributes
ItemType is a list of items (Table, Desk, Bookshelf, Chair)
Style is a type of style for the item (Circular table, Radial Desk)
I want to create the Items.Style field based upon a query of the StyleTypes. So if a user types "Desk" in Items.ItemType then the Items.Style field will be limited to only those Styles which match that selected item within the StyleTypes table.
Think thats clear enough, but my attempts have all failed, hope you guys can give me a push in the right direction, thank you!
View 4 Replies
View Related
Apr 5, 2006
Hi all,
I have very little knowledge of databases and even less about writing queries.
The problem:
I have a database that lists cities (such as Paris, London, New York etc) as rows and employment status (Full-time, Part-time, Unemployed etc) as columns.
I need to go through each city and record which employment status is greatest (for each city) and present it in a new column. I can do this manually but I’m sure a query can be created to automate the process.
Hope that all made sense. Can anyone suggest ideas on where to start?
Many thanks,
Carl
View 1 Replies
View Related
May 6, 2006
hi
have just designed a rather simple music database for my dad to use at home as he has large collection.
have a table with the heading"artist" and another one with "album" ...my problem is that on the table there maybe 1 or more instances with the same artist but with different albums...when i run a simple query for ..say artists starting with the letter"a" i may get about 10 cases of the same artist appearing in my query when all i want is one...(depending on if i may put in say one artist like abba having 10 albums etc)...i am entering each artist with the album each time so i may enter the artist in say 10 times....depending on how many albums etc
if you understand all that...i would be grateful if someone could help me with a simple query
alan
View 7 Replies
View Related
Jul 4, 2006
I have a query that returns the uncompleted jobs from a single table ( its a calls database)
all i need is query that returns the amount of uncompleted jobs onto the switchboard I.E whatshername has X amount of uncompleted jobs , i have done a search and most of the solutions are very complicated for what i want to do .....anyone any ideas ?? pls
View 2 Replies
View Related
Jul 6, 2006
Thanks in advance to anyone who helps.
SQL and Access are both new to me. I have purchased some books (which are still in the mail), and have gone through this forum (which seems to be a little more advanced for me at this moment).
I have a database that contains Business_Unit (Store Numbers), Post_Date (Last Date of Inventory), and other misc. stuff. Anyways, My goal is to pull the latest date of inventory for each individual store before the last ninety days. What I have so far:
SELECT DISTINCT informix_shrink_head.business_unit, informix_shrink_head.counting_event_id, informix_shrink_head.post_date, informix_shrink_head.delta_cost, informix_shrink_head.delta_count, informix_shrink_head.count_reason_cd, pcw_loc_master.closed
FROM informix_shrink_head, pcw_loc_master
WHERE (((informix_shrink_head.post_date)<=Date()-90) AND ((pcw_loc_master.closed) Is Null))
ORDER BY informix_shrink_head.business_unit;
However, I get the same store multiple times and for multiple post dates.
I do not even know if this can be done in one simple swoop, or if I need to create another table and re-query that? Any assistance or comments would be much appreciated.
Thanks,
A Gator
View 1 Replies
View Related
Sep 11, 2006
Hi guys. I have been away a while and boy am I rusty.
I would like to show how many available licenses there are. Here is what I have:
Software (Office 2003)
license purchased (8)
license used (2)
I added an expression along the lines of:
Available: Sum([tblSoftware]![Number of licences purchased]-[tblPC-LicenceRelation]![Number of licences])
This gave 14 and not the desired result of 6!!!
Simple I am sure!! :o
Phil.
View 4 Replies
View Related