473,799 Members | 3,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

select *, count(group), sum(number)

2 New Member
Hi everyone!
I'm sure my problem is pretty easy to solve but I've been working on it for a long and my my brain is not working correctly anymore.
I'm working with an AS400 and I mhave to do an "interface" in Access. It's like a little system to make a production plan. It must get information about part numbers, description, set where the part number belongs, quantity of part numbers that the set uses, stock number(this is a text value, it could be "re", "co", "pt", etc but I just use "co" and "re"), stock and production group.
To connect Access to the server I vinculated three tables: teils, strus and lgbs. To make things faster, I created a query and then used create tbale query to make a new table. Then did a form and added new fields on that table: daily use, prod. days, stock on hand and period days.
I did a form and it works right. But my problem is from the first query:
SELECT DISTINCT RHDBD_16_STRUS. STFIRM, RHDBD_16_STRUS. STKOMP, RHDBD_16_TEILS. TEBEZ1, RHDBD_16_STRUS. STBGNR, RHDBD_16_LGBS.L SLANR, RHDBD_16_TEILS. TEMAGR, RHDBD_16_LGBS.L SLGBE INTO PLANEACION
FROM RHDBD_16_LGBS, RHDBD_16_STRUS, RHDBD_16_TEILS
WHERE (((RHDBD_16_STR US.STFIRM)="5") And ((RHDBD_16_STRU S.STKOMP)=(RHDB D_16_TEILS.TETE NR) And (RHDBD_16_STRUS .STKOMP)=(RHDBD _16_LGBS.LSTENR )) And ((RHDBD_16_STRU S.STBGNR) Not Like "ES*" And (RHDBD_16_STRUS .STBGNR) Not Like "MS*") And ((RHDBD_16_LGBS .LSLANR)="RE") Or (RHDBD_16_LGBS. LSLANR)="CO") And ((RHDBD_16_TEIL S.TEMAGR)="ASOX ")
ORDER BY RHDBD_16_STRUS. STBGNR;
This one is from the vinculated tables, and I want to get in the same query one to get the count of part numbers by set. This is the query that does it:
select count(RHDBD_16_ STRUS.STKOMP) group by RHDBD_16_STRUS. STBGNR.

I couldn't find the way to do it, so I used a code like this:
strPalabrasegun da = STBGNR
Set prueBa = DBEngine.OpenDa tabase("C:\Docu ments and Settings\mzarat e\
Mis documentos\PRUE BA\PLANEACION_D E_LA_PRODUCCION _PEM.mdb")
strSQL = "SELECT * FROM PLANEACION where PLANEACION.STBG NR like '*" & strPalabrasegun da & "*'"
Set taBla = prueBa.OpenReco rdset(strSQL, dbOpenDynaset)
With taBla
.MoveLast
.MoveFirst 'Voy al primer y al último registros con el objetivo de contar los registros.
cuentapalabra = taBla.RecordCou nt
Texto26 = cuentapalabra

That does it fast, no problem if it keeps so.
But there's another problem, the fields "set" and "part number" could be the same in several entries (does it mean "registro") . I mean, the same combination part number-set could be in many entries. So, it could be fixed with a select distinct, but the fields stock number or stock make it change. I know it's the same but I can't find a way to show it once.
Now I'm trying to use a sum, but I'm having problems again:
SELECT Sum(PLANEACION. LSLGBE) AS SumaDeLSLGBE
FROM PLANEACION
GROUP BY PLANEACION.STBG NR;
This makes it, but the same problem: how do I get it in an only query or how do I use it for VB. Well, actually I have it in VB, but I don't know the way o show the result from the sql statement in a textbox.
As you can see I'm not fine and maybe I'm not in the right way, so if you can help me to get the three queries in one or to get the resulta from my query to a textbox.
Thanks for the time and I hope you have understood -because the trouble is a little confussing and my English is not good enouh-, if you didn't, please write to this e-mail:
**Email removed as per site rules**
Thank you again and have a nice -amazing- day!
Jun 29 '07 #1
1 3618
NeoPa
32,579 Recognized Expert Moderator MVP
I'm sorry to have to say this, but your question is too long and complicated to understand.
I appreciate that you made a great deal of effort to explain yourself, but the simple fact is, that something this long and complex is hard enough to understand (don't forget we can't see what you're talking about) when written in clear English (which even English people rarely manage well). When words are missed out or misspelled it is just too difficult to understand. I'm sorry, and I'm not trying to be at all critical. You've made a good attempt, but it's simply too hard to understand.

MODERATOR.
Jul 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4230
by: Willem-Jan Selen | last post by:
Hie everybody, I have a problem with the following, I have a table with a row containing numbers with 2 decimal places. I want to count the sum of these numbers but my valuw returned is far to high. I think the SUM string doesn't look at the decimal place. The same is with the AVG string
2
9512
by: Chris | last post by:
Hello all, I'm having some trouble setting up a query. Background: The table TBLSCREEN stores data about screenings of patients/subjects for eligibility to participate in a health study. A subject can be screened multiple times. The simplified table structure is
2
1760
by: Peter Bailey | last post by:
I have a query that creates a graph of bookings from the course start date looking back 20 weeks based on a running sum. I also have a query that counts the number of bookings before that 20 week date for that particular course start date. What they want is to start the 20 week running sum from the previous total. for ex
2
3426
by: tedhekman | last post by:
Hi there! I am pretty new to Access, have been loving learning it! I have a problem here I can't even begin to figure out. Here is what I need: Given 1 Date and 1 Store, retrieve the following information: 1. # of each product sold in STORE for DATE, and for the 3 days prior to DATE 2. Sum # of each product sold in STORE for days 5-8 previous to DATE 3. Sum # of each product sold in STORE for days 9-12 previous to DATE 4. Sum # of each...
3
2269
by: lagj | last post by:
Using MySQL 5.0.15 I am no expert so maybe I am deeply misundertanding how this should work. I have a relatively complex quey with joins and a subquery (it is probably far from optimized, but that is another issue; right now I am more interested in correctness than speed). If I do not put a GROUP BY clause then the query returns a number of rows, as expected. If I add a GROUP BY clause, I get an empty set! My understanding of the...
3
6908
by: JDiamond | last post by:
Hi, I have a table called Hosts. The Hosts table contains the following fields: Each field represents a step in the project. The tech that completes each step initials the respective columns using a combo box within a form. These initials are stored in an engineer table in which the combo
2
1439
by: trihanhcie | last post by:
Hi, Well the following query is not the one i will use but it's the same prob : SELECT sum(country_id ) , count( country_id ) FROM Tbl_Country, Tbl_config WHERE country_id =1 Well ...the result should be sum(country_id )= 1 et count( country_id
10
10004
by: Rudolf Bargholz | last post by:
Perhaps some kind soul could help me out with an SQL I have been trying all day to get to work, where one colum is just not summing up the way I want it to. I have the following data GRP_SEQ ITEM_SEQ NR_ITEMS PERSONS_SEQ 1 A 2 aa 1 A 2 bb
1
1657
by: godfather96 | last post by:
I am using a web control called eXml which is an extention to ms xml web control which supports xslt 2.0 when trying to group elements i receive the following error: group-by is not a valid extention element is there a namespace or something a need to add. my source is below
0
10485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10252
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.