Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / July 2007

Tip: Looking for answers? Try searching our database.

Two simple questions (merge two tables and group problem)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nasko - 31 Jul 2007 12:26 GMT
I hope you can help me with the next problems I have:

Question 1: Merge two tables
I  have a table with shipped cartons in peak and average month

ShippedAverage
ShippedPeak

I like to have a querry combining both tables like

SELECT * FROM ShippedAverage
AND
SELECT * FROM ShippedPeak

Is this possible? How can I do this in the design view?

Question 2: Group problem

I have two different types of shipping tables

ShippedCartons, with fields

ProductCode, NrShippedCartons
1234             10
1234             15
2345             10

And ShippedPallets
ProductCode, NrShippedPallets
1234             2
1234             4
2345             1

I like to have a summary of both

SELECT ProductInfo.ProductCode,
           sum(ShippedCartons.NrShippedCartons),
           sum(ShippedPallets.NrShippedPallets)
WHERE productInfo.ProductCode = ShippedCartons.ProductCode
  AND   productInfo.ProductCode = ShippedPallets.ProductCode
GROUP BY  productInfo.ProductCode

To get next info
ProductCode SumOfCartons SumOfPallets
1234            25                   6
2345            10                   1

But the values are higher, probably because he selects too much records for
the sum (double records?).

How do I solve this?

Thanks in advance again!!

Regards,

Nasko
Nasko - 31 Jul 2007 12:28 GMT
I found out that I can solve the first problem by using the UNION ALL command.

That leaves only the second question...

Regards,

> I hope you can help me with the next problems I have:
>
[quoted text clipped - 53 lines]
>
> Nasko
scubadiver - 31 Jul 2007 13:22 GMT
Why do you have two different tables for shipped pallets and cartons?

Signature

www.ae911truth.org

> I found out that I can solve the first problem by using the UNION ALL command.
>
[quoted text clipped - 59 lines]
> >
> > Nasko
Nasko - 31 Jul 2007 13:40 GMT
To be honoust, this is only an example.

using the real data, one table coming direclty from the client shows the
cartons that are shipped directly and another table gives the cartons that
need extra handling before being shipped. They dont have the same format so I
cannot ´union´ them. I made this example to better explain the problem I
have. (The pallet field came into the example because I have to calculate
everything in pallets at the end...)

Regards,

> Why do you have two different tables for shipped pallets and cartons?
>
[quoted text clipped - 61 lines]
> > >
> > > Nasko
scubadiver - 31 Jul 2007 13:52 GMT
The only suggestion I can make is if you design a query and show the two
tables. Insert the following fields

ShippedCartons.ProductCode
ShippedCartons.SumOfCartons
ShippedPallets.ProductCode (Insert a criteria here:
[shippedcartons].[productcode])
ShippedPallets.SumOfPallets

Hopefully you will then get this:

ProductCode  NrShippedCartons ProductCode  NrShippedCartons
1234             10                       1234              2
1234             15                       1234              4
2345             10                       2345              1

Then you can make the second "ProductCode" column invisible and base a
totals query on this.

The alternative is to create a join between the two product codes in the top
pane of the query and then you should get the same result.

Signature

www.ae911truth.org

> To be honoust, this is only an example.
>
[quoted text clipped - 72 lines]
> > > >
> > > > Nasko
Nasko - 31 Jul 2007 13:42 GMT
The exact querry. I also have a problem that the sum total pallets is only
calculated when there is copacking for a certain ProductCode.

SELECT ProductCodes.ProductCode,
      AllOut.ShippedCartonNr,
      AllOut.ShippedInners,
      AllOut.ShippedCartonNr Mod ProductCodes.CartonsPerpallet AS
LooseCartons,
      ProductCodes.CartonsPerPallet,
      AllOut.ShippedCartonNr\ProductCodes.CartonsPerpallet AS FullPallets,
      [LooseCartons]/ProductCodes.CartonsPerPallet AS PickedPallets,
       
AllOut.ShippedInners/ProductCodes.InnersPerCarton/productCodes.CartonsPerPallet AS InnerPallets,
      [CopackAll].[ShippedCartonNr]/[ProductCodes].[CartonsPerPallet] AS  
CopackPallets,
      [FullPallets]+[PickedPallets]+[Innerpallets]+[CopackPallets] AS
TotalPallets
FROM (ProductCodes LEFT JOIN AllOut ON ProductCodes.ProductCode =
AllOut.ProductCode) LEFT JOIN CopackAll ON ProductCodes.ProductCode =
CopackAll.ProductCode;

> Why do you have two different tables for shipped pallets and cartons?
>
[quoted text clipped - 61 lines]
> > >
> > > Nasko
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.