Need to group & sum items & sub items into one record
I'm having an issue creating a report that can group & sum similar items together (I know in some ways, the requirement doesn't make sense, but it's what the client wants).
I have a table of items (i.e. products). In some cases, items can be components of another item (called "Kits"). In this scenario, we consider the kit itself, the "parent item" and the components within the kit are called
"child items". In our Items table, we have a field called "Parent_Item_Id". Records for Child Items contain the Item Id of the parent. So a sample of my database would be the following:
ItemId | Parent_Item_Id | Name | QuantityAvailable
1 | NULL | Kit A | 10
2 | 1 | Item 1 | 2
3 | 1 | Item 2 | 3
4 | NULL | Kit B | 4
5 | 4 | Item 3 | 21
6 | NULL | Item 4 | 100
Item's 2 & 3 are child items of "Kit A", Item 5 is a child item of "Kit
B" and Item 6 is just a stand alone item.
So, in my report, the client wants to see the SUM of both the kit & its components in a single line, grouped by the parent item. So an example of the report would be the following:
Name | Available Qty
Kit A | 15
Kit B | 25
Item 4 | 100
Any idea how I can setup my report to group properly?
Thanks in advance.
Hi Goalie,
I couldn't not able to understand that what is the base input shown. whether it is the data-set or any base table.
If it is a base table then you can use the following query to grab your output.
If you don't want to group in the query then you can return the simple select of the output and group in the tablex it self.
/******************* Data preparation *******************/
DECLARE @TableData AS TABLE (ItemId TINYINT, ParentItemId TINYINT, Name VARCHAR(10) , QuantityAvailable TINYINT)
INSERT INTO @TableData (ItemId, ParentItemId, Name, QuantityAvailable)
VALUES (1, NULL, 'Kit_A', 10)
,(2, 1, 'Item_1', 2)
,(3, 1, 'Item_2', 3)
,(4, NULL, 'Kit_B', 4)
,(5, 4, 'Item_3', 21)
,(6, NULL, 'Item_4', 100)
/******************* Main Query *******************/
;WITH CTE_Data
AS
SELECT RwDt.ItemId, RwDt.ParentItemId, RwDt.Name, RwDt.QuantityAvailable
FROM @TableData RwDt
WHERE ParentItemId IS NULL
UNION ALL
SELECT Tp.ItemId
, COALESCE(Tp.ParentItemId,CTE_Data.ParentItemId)
, CTE_Data.Name
, Tp.QuantityAvailable
FROM @TableData Tp
INNER JOIN CTE_Data ON TP.ParentItemId = CTE_Data.ItemId
SELECT NAME
, SUM(QuantityAvailable) QuantityAvailable
FROM CTE_Data
GROUP BY NAME
Kindly mark it answer if it helps you..
Cheers.
Shivendra
Similar Messages
-
Need help in combining two similair SQLs into one
DB Version:10gR2
I need to combine the following two queries into one query and return the following three columns
Unprocessed Quantity1,Unprocessed Quantity2, Total Uprocessed Cost
Unprocessed Quantity1 can be determined using
select t.ITEM, sum(t.QTY)
from (select cd.ITEM_ID ITEM, cd.ACTL_QTY QTY
from CONVEY_HDR ch, CURRENT_INVN cd, ALLOC_HDR ah
where ........
UNION
select sd.ITEM_ID ITEM, sd.INVN_QTY QTY
from shp_dtl pd
UNION
Select item_id, inv_qty from another table
GROUP BY.....
ITEM SUM(T.QTY)
88JAT 25
000002395 1
300108396 27
000004397 7
73984290 15Unprocessed quantity2 can be determined using
select t.ITEM, sum(t.QTY)
from (select cd.ITEM_ID ITEM, cd.ACTL_QTY QTY
from CONVEY_HDR ch, CURRENT_INVN cd, ALLOC_HDR ah
where rownum<6
group by t.ITEM
order by t.ITEM;
ITEM SUM(T.QTY)
189436171 2
009438837 160
000040685 16
000032410 18Total Unprocessed Cost can found using the sum of Quantities for a particular Item from above two queries multiplied by
ITEM_COST for that ITEM (which is found in ITEM_DTL table). For every item; ITEM_DTL.item_id=CARTON_dTL.carton_id
Total Unprocessed Cost= (Unprocessed Quantity1+Unprocessed Quantity2)*ITEM_DTL. ITEM_COST
Note: Unprocessed Quantity2 query looks very similair to first SQL in UNION of Unprocessed Quantity1, but ah.STAT_CODE < 90 for Unprocessed Quantity2 query
Edited by: user636669 on Jan 14, 2009 10:40 AM
Edited by: user636669 on Jan 14, 2009 10:57 AM
Corrected typo
Edited by: user636669 on Jan 14, 2009 7:07 PMHi,
Put the two queries you posted in sub-queries. You can then use their result sets as if they were tables.
Do something like this:
WITH uq1 AS
select t.ITEM, sum(t.QTY) AS total
from (select cd.ITEM_ID ITEM, cd.ACTL_QTY QTY
from CASE_HDR ch, CASE_DTL cd, ASN_HDR ah
... the rest of your first query goes here
, uq2 AS
select t.ITEM, sum(t.QTY) AS total
from (select cd.ITEM_ID ITEM, cd.ACTL_QTY QTY
from CASE_HDR ch, CASE_DTL cd, ASN_HDR ah
... the rest of your second query goes here
SELECT uq1.item
, uq1.total AS "Unprocessed Quantity1"
, uq2.total AS "Unprocessed Quantity2"
, (uq1.total + uq2.total) * dtl.item_cost
AS "Total Uprocessed Cost"
FROM uq1
JOIN uq2 ON uq1.item = uq2.item
JOIN item_dtl dtl ON uq1.item = dtl.item;If some items are in uq1 but not in uq2 (or vice-versa), then you'll probably want to do outer joins.
I don't have any of the tables used, so I can't test this myself.
If you need more help. then post a little sample data from each of the tables, and the results you want from that data.
It looks like you're doing the same join in each of your original queries.
You can add another sub-query that does that join once, and then use that sub-query in sub-queries uq1 and uq2. -
As made clear in the title:
I'm trying to create a Windows partition using Boot Camp. An error comes up telling me that I need to reformat my current partition(s) into one single partition. However, it's already formatted in the correct format, and is already a single partition.
My computer recently had a kernel panic, which apparently the corruption was in the system and needed to be erased and re-installed. I have a complete back-up using an external hard drive, and I am definitely not willing to do another one of those to reformat a partition that is already singular. I restarted the computer after ejecting my back-up, and after turning off time machine (thinking that boot camp was recognizing it as a secondary partition), however the error still occurs.
Is there any way to get around this?diskutil list:
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *750.2 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 749.3 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: Windows7 *2.9 GB disk1
diskutil cs list:
No CoreStorage logical volume groups found
mount:
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk1 on /Volumes/Windows7 (udf, local, nodev, nosuid, read-only, noowners)
From my very basic knowledge - it still looks as if there is only one partition (not including the windows 7 CD necessary to install the windows partition). -
TS1649 Hi, can I merge the contacts groups on my iPhone 4 into one group?
Hi, can I merge the contacts groups on my iPhone 4 into one group?
You can't merge chat threads.
-
More than one records merge into one record
Hi,
I would like to merge multi records into one record.
For example
program_id campus_code
12345 ABC
56789 ABC
56789 EFG
56789 XYZ
98765 XYZ
the output is as follows:
program_id campus_code
12345 ABC
56789 ABC EFG XYZ
98765 XYZ
How can I get this result? Thanks in advance.Go to asktom.oracle.com and search for stragg
Regards,
Steve Rooney -
ALV Display for Item & Sub-Item Level
Hi Experts,
i am developing one report and i want the display it in ALV as shown below.
Item Level:
Tax Jurisdiction state current balance prior balance
3900000 LA 10000 15000
Sub-Item Level:
Jurisdiction Cd. Posting Date Type Doc. no. Amount
3902948101 05/03/2008 AR 139 30,998.00
3902948102 05/06/2008 AR 176 -56,987.00
3902948123 05/11/2008 178 -20,987.50
3902948190 05/20/2008 AP 189 76,000.00
3902948108 05/22/2008 GL 192 45,060.50
Account Total 74,164.00
How can i achieve this for displaying Item Level And Sub-Item Level.
Thanks & Regards,
Ramana.hi,
Plz refer this link for displaying hierarchical list in ALV.
http://voiceofabap.blogspot.com/2008/05/how-to-use-alv-for-hierarchical-lists.html
regards
Sumit Agarwal -
How to change a item property just for one record
Hi,
My Requirement is, when a new record is inserted i want item1 to be enabled(which is disabled by default) only for this new record. when I implement the following code, entire column is enabled intead of just for one record.
The code I have written in WHEN-NEW-RECORD-INSTANCE trigger is
app_item_property.set_property('block1.item1', ALTERABLE_PLUS, PROPERTY_ON);
app_item_property.set_property('block1.item1', ENTERABLE, PROPERTY_ON);
please help!
Thanks
SunnyThe code I have written in WHEN-NEW-RECORD-INSTANCE trigger is
app_item_property.set_property('block1.item1', ALTERABLE_PLUS, PROPERTY_ON);
app_item_property.set_property('block1.item1', ENTERABLE, PROPERTY_ON);What is APP_ITEM_PROPERTY? This is not a Valid Oracle Forms Built-in. I don't see how your When-New-Record-Instance (WNRI) trigger will compile.
To change the properties of a specific instance of an item you would use the Set_Item_Instance_Property built-in and then there are only a few properties you can change; which are: BORDER_BEVEL, INSERT_ALLOWED, NAVIGABLE, REQUIRED, UPDATE_ALLOWED and VISUAL_ATTRIBUTE. To make a specific instance of "ITEM1" Insertable and Updateable you would use the following:
Set_Item_Instance_Property('YOUR_BLOCK.ITEM1', CURRENT_RECORD, INSERT_ALLOWED, PROPERTY_TRUE);
Set_Item_Instance_Property('YOUR_BLOCK.ITEM1', CURRENT_RECORD, UPDATE_ALLOWED, PROPERTY_TRUE);However, if you have set the ENABLED property of ITEM1 to NO in the Forms Builder, you will not be able to "Enable" the item using Set_Item_Instance_Property. You will need to make the item Enabled and set the INSERT/UPDATE properties to NO.
Hope this helps,
Craig B-)
If someone's response is helpful or correct, please mark it accordingly. -
afternoon Gurus.
I take it by the errror messages produced I'm not able to do this..
select ....
address_line1||', '|| address_line2||', '|| address_line3||', '|| city|| Supplier_Address
from...
..in my XML Publisher xsl Data Template file..
Caused by: org.xml.sax.SAXParseException: <Line 13, Column 20>: XML-20201: (Fatal Error) Expected name instead of |.
So how can I acheive putting several fields into one like you can in SQL?
THanksForLooking..
AlUntested, but try the following:
SELECT DISTINCT
fnd.CREATION_DATE
,fnd.user_name
,fnd.start_date
,per2.last_updated_by
,per2.last_update_date
,per2.employee_number
,per2.EMAIL_ADDRESS
,per2.full_name
,fnd.LAST_LOGON_DATE
FROM fnd_user fnd
where fnd.End_Date is null
left outer join per_people_f per2 on ( fnd.employee_id = per2.person_id
and SUBSTR(per2.LAST_NAME, 2, 6) not like 'some characters'
and per2.EMAIL_ADDRESS LIKE '%priddle%' )
ORDER BY 2 ASC;Investigate multiple outer joins using the LEFT OUTER JOIN syntax
http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/queries006.htm#SQLRF52354 -
Multiple information into one record in rms
Hey all,
I am developing a Calendar application and currently implementing a Notes system for the user to store notes for a particular day.
A sample note would consist of:
Title: Dinner at Mark's
Content: Dinner at Mark's house, 6pm sharp. Bring Joseph along.
Each Note has a title and a content, but I have no idea how to store these 2 information into 1 record in a record store.
I thought of 2 ways, one is to delimit them by some funny characters, 2nd is to use two record stores(bad idea).
Can any body guide me along for this? I have seen examples but they only use 1 single string to store.What about a DataInput- and OuptutStream and using read/writeUTF()?
Should work just fine for reading multiple string items without using a delimiter. -
BOM-Delivery(Main item-Sub item)
Hi,
Issue is:
Availability check in Sales Order is missed and delivery has been done only for main item without showing any errors.
No reduction in stock of finish goods.
No Error message in delivery and in billing.
Only mainitem is flowing in documents and no subitems in the document.Even in confirmed order qty is shown for the main item only.
How to restrict this.
Friends kindly help.
RegardsHi
We have maintained the availabilty check for all materials and also checked in CS03 we have maintained L in item category.
The problem is that stock is not getting reduced because the subitems are not flowing in the doc and the mainitem is not getting restricted from delivery and billing even when there is no confirmation for subitems.But mainitem is getting confirmed.
Kindly help
Regards -
Group itens from shopping cart into one PO
Hi experts
I am using SRM 5.5, extendeed classic scenario, I am using automatic grouping, my problem is I need that several shopping carts creates just one PO if the requestor are the same.
What BDI can I use ?
Thanks
NilsonHi Nilson,
For Grouping shopping carts to create either P.Os or BID invitations there is no need to use a BADI. You have to execute the report <b>BBP_SC_TRANSFER_GROUPED</b> using SA38 transaction.
You can specify your criteria in that like group all SCs from a particular P.Org, P.Group, Product Category, Product etc.You can schedule a back ground job for this at particular intervals so that it automatically groups all the SCs as per the specified criteria and create either P.Os or BID invitations as per your requirement.
Also in SPRO > IMG > SRM > SRM Server > Sourcing specify your sourcing criteria as Auto grouping etc etc.
A single P.O is only created when the vendor is same for all the items that are being sourced otherwise different P.Os will be created for different vendors.
Hope this makes you more clear. Clarifications are welcome.
Rgds,
Teja -
Grouping synced audio + video clips into one clip?
I've been asked to edit some footage together that was shot by some other people. They recorded the audio separate from the video on a Marantz device, but they used a clapboard to mark everything so it shouldn't be too much of a problem to sync the audio files with the video files.
I can do that in the timeline, but I'd like to know if I can take multiple audio files and sync them with the one large video stream and have them treated as one single clip so I can easily cut them and put them in the timeline as usual?Just put them all in to a timeline and when you have them synced properly export the timeline as a reference or self-contained quicktime and re-import that file.
Caleb -
I need to combine two apple id's into one
The ultimate issue is that I have 2 apple ID's and I am trying to switch my me.com address to my primary apple id. Is there any way to combine 2 apple accounts?
Is it the case that you are using the @me.com ID for iCloud and the other one for iTunes?
You can't merge accounts or transfer iTunes purchases from one Apple ID to anothe : but there is no problem about using two IDs.
Use your ex-MobileMe email address (which is also an Apple ID) for iCloud for syncing email, contacts, calendars, bookmarks, and PhotoStream.
Use your other Apple ID as before for iTunes, iTunes in the Cloud and iTunes Match.
There's no conflict about doing this, and you won't even notice as Keychain will log you in with the correct ID in each case. It's also better security not to have your iTunes login also your email address, given the number of complaints about hacked iTunes accounts. -
Rollup errors - why not aggregate all rule violations into one record.
Hi there
We are using data rules on a target table and for each incoming row which violates a data rule a separate record is written to the error table. we have set the rollup errors to Yes. I would have thought this would have been sufficient but have read another post which talks about mapping from this error table into another custom error table. We could do this but I'm concerned about having two error tables instead of just the one.
Any ideas/advice?
Many ThanksHi,
If u believe what ever error table that u are using meets ur requirement for tracing the data then u donot need to maintain a separate error table as it would eat up on ur table spaces and also u have to take into consideration the maintenance cost for the same.
If u want a centralized view of all error tables in a single table then it would be a good idea to do it.
Regards
Bharath -
PGI for both main and sub items (Sales BOM)
Hello SD friends,
I'm trying to map some BOM scenario.
Only main item should be relevant for princing.
Here's what I've done :
1. Create sales BOM via CS01
2. Maintain item category group ERLA for main item and NORM for sub item MM01
3. Maintain item category TAQ for main item and TAE for sub item VOV4
When I wanna do PGI, system creates material document only for main item.
Which means that PGI has not been done for sub items.
Is there any way to make PGI possible for both main and sub items ??
Regards,
Bahia.Can you clear, that why you want to issue both Main item/Sub Item, where your pricing is @ main item level.
in Main item level Pricing, Main item itself includes components. Once you issue the main item. from Inventory this main item wil be reduced.
Eg: In Case of Main Item- Computer (Assume Components - Monitor , Keyboard , CPU & Mouse)
Price for Computer - $1200. Component prices individually- $300 , $100, $700, $100 - These prices applicable only when you sell as BOM at Subitem level Pricing Or Seperately )-
In SO: - Order Computer (System explodes Components to verify,which are the subitems consists in Main Item)
DEL:- Components will be copied in Delivery , but not for dispatch (Sch Line Cat:CT has these controls)
Inv: Only Main item will be displayed for print.
NOTE: for your requirement, you can change the Schline Category from CT - CN- which is relevant for delivery with movement type i601 -in SO. Then you can dispatch components & these components will not copied into Invoice ,as they are not relevant for billing.
If you want CN has to determined automatically, maintain Schline Category determination accordingly.
Hope it helps,
Any info, please revert
Maybe you are looking for
-
ITunes will not open - hangs up every time
I am running os x 10.8.5, on a mac book pro 2.4 ghz intel core 2 duo. iTunes will NOT open and run. It starts up, then hangs, nonresponsive, every single time. NOTE - I already reinstalled iTunes, to no avail.
-
HT1386 all my music in my library on my PC is not downloading to my IPAD, why?
All my music in my Itunes Library on my PC is not downloading to my new IPAD IOS6, why not? I have music in my library that was not purchased from Itunes (was CD's I purchased and downloaded into my PC) that is not syncing to my new IPAD IOS6, why n
-
Missing HP workflows in OSX Mavericks
After the move to Mavericks the work flow appears as depicted below. Please tell me how to reinstall the workflow automator components.
-
SXMB_MONI : Log Version
Hi Everybody, I am working on a SOAP to Proxy Synchronous Scenario.When I am testing this interface we are getting a log version entry (Grey coloured dot symbol) in SXMB_MONI whenever the response fails from ECC and sometimes doesn't update SXMB_MON
-
HT5622 how can we change apple id username...??
How can we change apple if username