Hi
I have a problem which I cant quite solve.
I have a query that groups records together to get a Total Price.....
Group....... Total Quantity....... .....Price
1............ .....450....... .............68 9.29305
2............ .....300....... ............522 .6018875
3............ .....1035...... ...........889. 7918
4............ .....750....... ...........799. 4961375
I then have another query that shows individual quantities
Group....... Quantity Total Quantity....... .....Price
1.............. ...50.......... .......450 ............... ..689.29
1.............. ...75.......... .......450 ............... ..689.29
1.............. ...100......... ........450 ............... ..689.29
1.............. ...100......... ........450 ............... ..689.29
2.............. ...150......... ........300 ............... ..522.60
2.............. ...150......... ........300 ............... ..522.60
3.............. ...435......... ........1035... ..............8 89.79
3.............. ...600......... ........1035... ..............8 89.79
4.............. ...750......... ........750 ............... ..799.50
But i want my table to look like this (see below) without the duplication of Total Quantity and Price
Group....... Quantity Total Quantity....... .....Price
1.............. ...50.......... ............... ............... ..689.29
1.............. ...75.......... ............... ............... ...689.29
1.............. ...100......... .............. ............... ..689.29
1.............. ...100......... ........450 ............... ..689.29
2.............. ...150......... ............... ............... ..522.60
2.............. ...150......... ........300 ............... ..522.60
3.............. ...435......... ............... ............... ..889.79
3.............. ...600......... ........1035... ..............8 89.79
4.............. ...750......... ........750 ............... ..799.50
I then want to export it to excel.
I can do it in a report by adding Grouping levels but it doesnt look good when exported to excel.
Any ideas on how i can do this?
Thanks
1 1693 NeoPa 32,568
Recognized Expert Moderator MVP
I think your table design is a little suspect - as we need to assume that the price is the same across various records of the same group. Not normalised ( Normalisation and Table structures).
However, overlooking that for now, there are two possible approaches I can see : - Recommended - Export the basic data into Excel and let Excel handle totalling (It's inbuilt - Data / Subtotals ...).
- Something like the following :
- SELECT [Group],
-
[Quantity],
-
[Price]
-
FROM tblData
-
UNION ALL SELECT [Group],
-
Sum([Quantity]),
-
[Price]
-
FROM tblData
-
GROUP BY [Group],[Price]
-
ORDER BY [Group],[Quantity]
Beware the total only appears at the bottom if you include the [Quantity] field in the ORDER BY clause. Sign in to post your reply or Sign up for a free account.
Similar topics |
by: teddysnips |
last post by:
Having recently had excellent service here (many thanks, Erland!),
here's another wee problem.
SQL 2000
I need to get a report which will display the movement of people thus:
ID DIRECTION NAME DATE VEHICLE REGISTRATION
The value of DIRECTION can be either "Inbound" or "Outbound"
|
by: rayt |
last post by:
I’m relatively new to XSLT and must admit I’m finding it refreshing, but every now and again something comes along which floors me. Maybe it’s the old imperative language background that is hard to shake. This is an example of a dark cloud in my brave new declarative world. Clearing duplication is bread and butter but in XSLT it’s not. The old preceding axis method is both too slow and destined to failure. The Muenchian method, although sublime...
|
by: MLH |
last post by:
I have a challenge...
In a table I call tblStuff4Letters with 3 fields:
, and . I have
a report called rptOutboundCorrespondence that feeds
off this table. Sorting & grouping is turned on in
that report - sorted first on (ascending)
then on (ascending). Of course,
there are more supporting fields in the table. The
above 3 are the significant fields for this discussion.
|
by: ahaque38 |
last post by:
Hello.
Using A2K SP3, I am having the following problem with a report using
"Sorting and Grouping".
I have recently added a grouping in the reports for
"Category2<>'CONTRACTS'".
I have reports at the plan (overall totals), department and division
levels which have sorting and grouping implemented with this new
|
by: Mike MacSween |
last post by:
tblCourses one to many to tblEvents.
A course may have an intro workshop (a type of event), a mid course
workshop, a final exam. Or any combination. Or something different in the
future.
At the moment the printed output is usually going to Word. It's turning into
an unholy mess, because I'm having to prepare umpteen different Word
templates, and the queries that drive them, depending on what events a
course has.
| |
by: Joe Schmoe |
last post by:
I am working on an ASP.NET application that generates an Excel 2003
spreadsheet on demand for the user, containing much sales information, and
then editable cells for the salerep user to enter forecasting information.
To make the spreadsheet easy to use, all cells are Protected except the
cells where the user will enter information.
However, since the information is presented in hierarchical layers, I need
to do grouping/outlining of the...
|
by: lennyw |
last post by:
Hi
I'm trying to use XSLT to do an xml to xml transformation where the
output xml contains summary data on the information in the input xml.
I've succesfully done a Muenchian grouping of the data from the input
xml file, but I can't see how to operate on the grouped result to
create and output the desired summary data. If someone could give a
reference to an example or provide an actual example I'd really
apprecaite it.
|
by: Bart op de grote markt |
last post by:
Hello,
I have a very simple problem which I will illustrate with an example:
I have the following records in my table:
A 1 C
A 2 C
A 3 C
B 8 K
B 9 K
|
by: Sandeep Singh |
last post by:
Hi,
How to do group by in XSLT ?
I tried on the following codes:
<files>
<file name="swablr.eps" size="4313" project="mars"/>
<file name="batboy.wks" size="424" project="neptune"/>
<file name="potrzebie.dbf" size="1102" project="jupiter"/>
|
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,...
|
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...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |