473,499 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get required output in sql

1 New Member
I writing a query as follow

Expand|Select|Wrap|Line Numbers
  1. Select  'I87' [Location],PC.Company_Name [Company Name], Q.Department,PG.Group_Name [Group Name], 
  2. PS.SGroup_Name [Sub Group Name], PB.Item_Code[Item Code],PB.Item_Name [Item Name], 
  3. Sum(isnull(BD.Qty,0)) [Quantity],  Sum(isnull(BM.Net_Amount,0))[Bill Amount]   from I87.I87.Bill_Master BM    
  4. inner join I87.I87.Bill_Detail BD on BM.BillNoWPrefix=BD.BillNoWPrefix  
  5. inner join Packing_Belongs PB on PB.Item_Code=BD.Item_Code    
  6. inner join Prop_Company PC on PC.Company_ID=PB.Company_ID and  PC.Company_ID='2'  
  7. inner Join PROP_Groups PG on PG.Group_Id=PB.Group_ID  and PG.Group_Id='49'  
  8. inner join Prop_SGroup PS on PS.SGroup_Id=PB.SGroup_ID and  PS.SGroup_Id='32' 
  9. inner join (Select Distinct Department from Packing_Belongs) Q on Q.Department=PB.Department and  Q.Department='Bakery' 
  10. where BM.Bill_Date between '9/5/2011' and '9/20/2011'  
  11. group by PB.Item_Code,PB.Item_Name,PG.Group_Name,PS.SGroup_Name,Q.Department,PC.Company_Name
and its output is as follow..

Location , Company Name, Department, Group Name, Sub Group Name Item Code, Item Name, Quantity, Amount

But I required output as following format as shown in Image attached with this query..

can any one tell me how can I do so??
** Edit **

Attached Images
File Type: jpg untitled11.jpg (18.2 KB, 146 views)
Sep 27 '11 #1
1 1473
Rabbit
12,516 Recognized Expert Moderator MVP
You can use a pivot to get the values of a column across the top, but it only allows the use of one aggregate. I suppose you could use two pivots and then join them.
Sep 27 '11 #2

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

Similar topics

3
3763
by: Derek Fountain | last post by:
Just asked a question regarding this little bit of XSL: --- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> ...
54
4022
by: bnp | last post by:
Hi, I took a test on C. there was an objective question for program output type. following is the program: main() { char ch; int i =2;
1
1828
by: Aalok | last post by:
This is what i want to do. Read a text file as an input and based on that file, Create an outpu text file which saves the contents of the input file in a specifi format in the output file. I...
8
1580
by: Greenhorn | last post by:
Hi, when i run the output file generated by using cc i get no output on my terminal. #include <stdio.h> main() { printf("Testing the printf functionality"); }
2
1040
by: Nick | last post by:
Hi, Is it possible to pass execution to a view (aspx file), let it do its job, and then capture the output? I want to achieve something like this during a HttpRequest: 1. Invoke the...
21
1781
by: Umesh | last post by:
/*program to search a* in a text file & write output in a file.* indicated any character*/ #include<stdio.h> #include<stdlib.h> int main(void) { FILE *f,*fp; f=fopen("c:/1.txt","r");...
10
1493
by: hpbrothers | last post by:
#include<iostream.h> #include<conio.h> void main() { int a,b,i,j,k=0,fg=0; for(i=0;i<5;i++) { cout<<"enter no."; cin>>a;}
3
9520
by: realmerl | last post by:
Hi All. I'm trying to transform a html document into plain text via xslt. Simple you say! (i hope) I have got it working, by using the magnificent <xsl:value-of select="."/>. This returns the...
6
4437
by: vijayarl | last post by:
Hi Everyone, i need to add a string in between the filename.so that new file will have the required filename. what am doing is reading the files from the directory & extract only the filename...
0
7006
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...
0
7169
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,...
0
7215
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...
1
6892
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...
0
7385
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...
0
5467
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,...
0
4597
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...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
294
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...

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.