473,809 Members | 2,940 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a query that combines multiple rows into one and...

Hi there

I am trying to create a database that generates delivery notes. I have an excel spreadsheet linked to the database. From the linked information I need to be able to create a delivery note. But in the table, there are multiple instances of an order number.

Order_No Branch Voucher Code
112 44 5
112 44 10
112 44 20

How can I create a report/delivery note so the data is all on one row...

Order No Branch Voucher Code 1 Voucher Code 2 ...
112 44 5 10 20


I really need some advice...my deadline is tomorrow :(

Thanks in Advance

Simon
Oct 19 '10 #1
11 1683
nico5038
3,080 Recognized Expert Specialist
Hi Simon,

For this we have the cross-table query that will make columns out of the Vouchers.

There's however a nasty side effect, as the content of the column will be changed into the column name. When you have no fixed max of vouchers per order, it's hard to create a report, as you won't know how many fields to place...

Do you know the max ?

Nic;o)
Oct 19 '10 #2
Rixxe
7 New Member
Perhaps if you post what you have so far in your DB, people might be able to have a look.
(Would make the solution a lot faster, seeing as you have a deadline.)
Would it not be easier, just to import the data into access, rather than link from excel?
Oct 19 '10 #3
Hi guys

Maximum number of voucher types per delivery note is 5.

How do I upload files to this forum? I am new to this unfortunately

Thanks in advance
Oct 19 '10 #4
Rixxe
7 New Member
Hi Simon,

http://bytes.com/faq.php?faq=vb3_rea...b3_attachments

Should help you attach your DB.
Oct 20 '10 #5
Simon Bernard
4 New Member
Hi Guys

Please see attached the database that I am working on

Any help would be hugely appriciated.

Some useful things to note
  • 1 Branch can order many Products
  • I want all the items ordered by the branch on the day that they placed the order to be on 1 document (Delivery Note). This in term means the Order No will appear once on the combined Delivery Note

Thanks in Advance

Simon
Attached Files
File Type: zip Order Database.zip (100.8 KB, 84 views)
Oct 22 '10 #6
nico5038
3,080 Recognized Expert Specialist
Try the next query to see how I forced the Products to appear in columns:

Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Max(Order.[Product Code]) AS [MaxOfProduct Code]
  2. SELECT Order.[Order Number], Order.Branch
  3. FROM [Order]
  4. GROUP BY Order.[Order Number], Order.Branch
  5. PIVOT DCount("Date","Order","[Order Number]='" & [Order Number] & "' and [Branch] = '" & [Branch] & "' and [Product Code] <='" & [Product Code] & "'");
  6.  
Some additional work is needed to get the "fixed" 5 columns, but I won't spoil your fun.

Nico
Oct 22 '10 #7
Simon Bernard
4 New Member
Hi Nico,

The code you wrote worked thanks mate.

Another thing, how would I get the Branch Address fields to appear on the same line as the order/branch?

E.g. Order No, Branch, Address 1, Address 2, P1, P2, P3
(P1,2,3) = Product Value 1 etc)

Thanks again mate

Simon
Oct 22 '10 #8
Simon Bernard
4 New Member
Hi mate

Thanks for the sending the code...it worked :D

How would I get the Branch Address fields to appear in the same line?

E.g.
Order No, Branch, Address1, Address2, P1, P2, P3

(P1,2,3 - the products associated to the order no)

Thanks again mate...sorry if this question appears twice, I wasnt sure if my last post was sent)

Cheers

Simon
Oct 22 '10 #9
nico5038
3,080 Recognized Expert Specialist
Just add them with the same value (Header row) as the two existing fields. When they aren't in the Order table, first JOIN the Customer table.

Nico
Oct 22 '10 #10

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

Similar topics

7
33315
by: RotterdamStudents | last post by:
Hello there, i have a strange problem. I can't get php to insert multiple rows at once in a MySQL database. I use the $sql = "INSERT INTO database (a,b,c,d,e) VALUES ('$a', '$b' ,'$c', '$d', '$e')"; I want to insert 5 rows at a time in the database, but it only inserts every 5th record. For example: 1. AA
4
4890
by: don.fleming | last post by:
Hi folks: Am doing a VBA SQL Select stmt with multiple rows found and not getting RecordCount > 1. I've verified there are multiple rows found by copying my SQL stmt from Debug window and pasting it to a query - retrieves many rows. I need to program to handle many Rows in VBA. Suggestions much appreciated! Here is an excerpt of my VBA code after the SQLstmt is built: Debug.Print SQLstmt Set RecSet1 = SQLtbl.OpenRecordset(SQLstmt)
5
6186
by: Arsen V. | last post by:
Hello, What is the optimal way to insert multiple rows (around 1000) from a web application into a table? The user enters multiple lines into a text box (up to 10,000). The ASP.NET application breaks that data into a string array. Each line is an item of that array. The user clicks Submit.
2
4362
by: ameshkin | last post by:
I know this is probably not too hard to do, but how do I display multiple rows of a mysql query/recordset. Im having trouble doing this. I don't just want to display them, but I want to make sure ONE field in each row gets a variable. The table name is RecentUploads, the field I want to pull is XML This is probably something simple that is more experienced, but I've only been doing this for a couple of months. Any help would be...
9
8011
by: kencana | last post by:
Hi all, I am a new bie in SOAP and PHP.I got one question about the data retrieval. I am able to retrieve the data successfully from my database. this is my sql statement: select roadname from address where postalcode Like '123%'; based on that sql query it should return me multiple rows value, but instead of that, it only return me the first row of the data.i can't see the rest of it.. I hope somebody can help me out from this problem....
12
2451
by: Michel Esber | last post by:
Hello, Db2 Linux LUW FP 15. Consider table A (ID varchar, EXECUTION_DATE date). a) I want to first retrieve all IDs that have not executed during the last 90 days: select distinct ID from table_B where NOT EXISTS
1
6055
by: gerbrandc | last post by:
Hello, how can I insert into the sql compact edition 3.5 multiple rows. I have following query INSERT INTO network (name, adname, timezone) VALUES ('rm', 'rm', 1), ('pm', pm', 1) , ('PLURIELLES', 'PLURIELLES', 1), ('SPORTS', 'SPORTS', 1);
9
3650
WyvsEyeView
by: WyvsEyeView | last post by:
I have a form that has four unbound combo boxes: cboType, cboVersion, cboStatus, cboReview. I want to write a query that basically lets users make selections in as many combo boxes as apply...only one, all four, or anything in between. Here is the query, with the "meat" of it sketched out. I'm not sure how to capture the "or any" designation & can't find instructions in any of my SQL references. I've tried everything I can guess at in the Query...
0
8050
bilibytes
by: bilibytes | last post by:
hi, i am trying to UPDATE multiple rows with mysql. I know how to do it with multiple queries but i think it would be less resource consuming generating mysql query code with php and update all one single step. here is the method i usually employ: $value_column_1 = array(); $value_column_2 = array(); for($i = 0; $i<= $number_of_updates; $i++){
1
1796
by: cronk005 | last post by:
I am fairly new to Database creation and have devised a nice database which does what I am hoping to do. Though I am sure there is an easier way of accomplishing many of the tasks I have done, as I learn I will adapt & change.. but. currently I want to create a query which will show me records which Contain the word "Checked-In" in any of 4 columns. So for example: TABLE = Patient Visits Columns Interested Include: Visitor1Status ...
0
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10643
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...
1
10391
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
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
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
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3015
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.