How to combine xdofx:substr with if: (conditional)?
HelloI want to display all records that begin with 'X '.
I'm getting with conditional section
<? If: xdofx:substr(Type,1,2) = 'X -'? >
This means that the field 'Type' must be passed to the function substr and be cut for the first two characters.
If there is first of all to the tanks are X - then the condition is met.
Report throws
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (unknown Source)
at java.lang.reflect.Method.invoke (unknown Source)
at oracle.apps.xdo.common.xml.XSLT10gR1.invokeNewXSLStylesheet (unknown Source)
at oracle.apps.xdo.common.xml.XSLT10gR1.transform (unknown Source)
at oracle.apps.xdo.common.xml.XSLTWrapper.transform (unknown Source)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO (unknown Source)
at oracle.apps.xdo.template.fo.util.FOUtility.generateFO (unknown Source)
at oracle.apps.xdo.template.FOProcessor.createFO (unknown Source)
at oracle.apps.xdo.template.FOProcessor.generate (unknown Source)
at RTF2PDF.runRTFto (RTF2PDF.java:629)
at RTF2PDF.runXDO (RTF2PDF.java:439)
at RTF2PDF.main (RTF2PDF.java:289)
Caused by: oracle.xdo.parser.v2.XPathException: Namespace prefix "xdofx" used but not declared.
at oracle.xdo.parser.v2.XSLProcessor.reportException(XSLProcessor.java:806)
at oracle.xdo.parser.v2.XSLProcessor.newXSLStylesheet(XSLProcessor.java:571)
... 14 more
Any suggestions?
Tags: Business Intelligence
Similar Questions
-
How to combine character animator with movement sequences after effects puppet?
Hey community! I hope that everyone is having a good day/night
So I used successfully the facial recognition to my really cool talking characters with character animator, and I intend to do the rest of the artwork of the puppet/movement/scene in After Effects, but...
After I imported the scene in After Effects, I noticed that I have no control over the assets any longer, and the composition is just the stage with none of the layers... If After Effects will play the scene and I would exprt but that's all.
How can I combine puppets of the face of the host character with puppets and gestural stage with After Effects? My guess is that my workflow control is false. Any help would be greatly appreciated
I did it by creating an image file separated with everything except the head and then using this second file to animate in Ae.
It's easy enough to create the second body file (I use Photoshop) by dragging the layers appropriate to the library. It should also be possible to use the library in Ae.
This works well for me and so far seems more flexible.
-
How to combine two bitmapData with blendMode?
I will simplify my case with an example:
Set 2 clips on the stage, each with a rectangle in it that have different colors. Put one on the other and apply upwards a certain blending mode that shows a visual difference. OK so what I have to do now is to capture the bitmapData both and it redraw in a single MovieClip, so what I need is to merge the bitmapData 2, which has worked well without a blendMode, but I can't make it work just with blendMode, can anyone help?
Here is the code I have so far (he located on the 1 frame of the main timeline):
import flash.display.Sprite; import flash.display.BitmapData; import flash.geom.Point; import flash.display.MovieClip; function makeTrans(targetArr:Array, container:*):void { var targetBitmapDataArr:Array = []; var maxBitmapDataWidth:Number = 0; var maxBitmapDataHeight:Number = 0; for(var i:Number = 0; i < targetArr.length; i++){ var target:* = targetArr[i]; var myRectangle:Rectangle = new Rectangle(0,0,target.width,target.height); var myMatrix:Matrix = new Matrix(); var myBitmapData:BitmapData = new BitmapData(target.width,target.height,true,0xFFFFFFFF); myBitmapData.draw(target,myMatrix,null,target.blendMode,myRectangle,false); targetBitmapDataArr.push(myBitmapData); maxBitmapDataWidth = Math.max(maxBitmapDataWidth,target.width); maxBitmapDataHeight = Math.max(maxBitmapDataHeight,target.height); } var finalBitmapData:BitmapData = new BitmapData(maxBitmapDataWidth,maxBitmapDataHeight,true,0xFFFFFFFF); var startPoint:Point = new Point(0,0); var mult:uint = 0x100; for (var j:Number = 0; j < targetBitmapDataArr.length; j++){ finalBitmapData.merge(targetBitmapDataArr[j],targetBitmapDataArr[j].rect,startPoint,mult,mult,mult,mult); } container.graphics.clear(); container.graphics.beginBitmapFill(finalBitmapData,null,false,false); container.graphics.drawRect(0,0,finalBitmapData.width,finalBitmapData.height); container.graphics.endFill(); } var transition:Sprite = new Sprite(); addChild(transition); makeTrans([mc1,mc2],transition);
If the two MovieClips are normal blendMode, it works very well, blendMode setting does not have the desired result, test and please let me know how to do this correctly. I do this for purposes of optimization, because in my real case, I have an entire Web site, I want to apply the mix mode affecting the performance of the current animations much and given that the blend mode is applied mainly background + a few decorations more on this, I think it would probably eliminate the need for permanent blendMode being all the time and just to get the result final background and then I can show only that and hide/disable everything else.
Thanks in advance!
Can you give an example more short which doesn't work as expected? I just did a little test with some bitmap icons - put the two on stage - one above the other the value mode of inverses of mixture, then a new bitmap of them... worked perfect. Here's the code I used:
var c:BitmapData = new BitmapData (32.37);
c.Draw (a);
c.Draw (b, NULL, NULL, b.blendMode);var f: Bitmap = new Bitmap (c);
addChild (f);First icon has an instance name, second is b... The new bitmap is exactly the same as the two on stage.
-
How to combine 2 VCenter with different subnet?
Hello
I had 2 x VCenter instance installed in two different subnet, internal production and one for the disaster recovery site, it is possible to make them connected to each other and then implement in the heart of vcenter beat builtin functionality?
Thank you.
OK, I'm a bit confused. You asked previously on vmotion or vcenter or esx hosts?
vCenter servers can be linked together without having to be in the same subnet.
Grouping of vcenters will allow you to have a single pain of glass view for the two vcenters and allow you to search your inventory full, but models are managed by the individual vcenters.
-KjB
-
How to use 'LIKE' operator/substr/instr with if condition?
Hello
How to use 'LIKE' operator/substr/instr with if condition?
I can use the following function:
<? xdofx:InStr('ssStatus','Open',1) = '0'? >
which returns true or false depending on ssStatus as Open *.
But when I try to use <? If: xdofx:instr('ssStatus','Open',1) = '0'? > calculating <? end if? >
It gives an error.
Any suggestion? OR a solution?
Thank you.
Published by: user12427117 on March 10, 2011 20:42
Published by: user12427117 on March 10, 2011 20:46You can try to use
0? >
Use contains to AS
-
How to make a sum of text_field or column with where condition?
Hi all
In Oracle forms 6i, I created a form in which there are 5 text_Items (with 20 none of the displayed fields) namely ACCOUNT FD DO, AMOUNT, INTEREST RATE, STATUS and INTEREST_YEAR.
FD ACCOUNT NO.
AMOUNT
INTEREST RATE
STATUS
INTEREST_YEAR
47665
50000
- 11.5
E
5750
37463
60000
12
D
7200
47651
100000
- 12.5
D
12500
34766
70000
11
E
7700
I want to make the sum of the INTEREST_YEAR where status = 'E '.
I created a TOTAL_INTEREST_YEAR name field in which I want to display the sum.
How the sum with where condition?
Thank you.
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
Oracle form Builder 6i.
Michael,
When you write the formula for a calculated item, it does not use PL/SQL expressions (to include built-in DECODING) in Forms 6i. If there was no conditional control over your calculation, you can simply make your article a summary point and perform the summation over column interest_rate . However, because your calculation depends on the value in the STATUS column, you will need to use a combination of a calculated item and a summary article because you can't use an IF, DECODE or any other PL/SQL statement in the formula for the calculated item. Therefore, you need to create a function in the knot of program units and call the function in your formula. I tested it using the following code and it worked correctly.
First, create the following function in the node of the object browser program units.
FUNCTION calc_interest RETURN NUMBER IS n_ret_val NUMBER := 0; BEGIN IF ( :YOUR_BLOCK.STATUS = 'E' ) THEN n_ret_val := :YOUR_BLOCK.interest_rate; END IF; RETURN n_ret_val; END calc_interest;
First, you must change the property to BLOCK request all archives = Yes
Then, open the palette of your calculated item property, and set the following properties:
1. calculation = Formula
2 property Forumla = CALC_INTEREST
3. point data base = No.
Now create a second item in the table not based on in your block that will display the amount of the interests summarized. Open the palette property for this element and set the following properties:
1 Data Type = number
2 calculation Mode = Summary
3. function = sum
4 summarizes point = "name of your element calculated.
5 base of data point = No.
6 canvas = "your canvas.
When you query your block, you should see the sum of all records where STATUS = 'E '.
It worked for me, in my example form that I created so this should work for you.
Craig...
-
How to combine libraries of photos with pictures in Windows Media Center
I want to know how to combine images with windows media center libraries pictures how it's done?
Original title: search search index indexing re-indexing re-index research research research service troubleshooting troubleshooting
Hello
What operating system do you use?
Please provide information more precise about what you are exactly doing.
Refer to the below link mentioned before asking your question so that you can provide all the relevant information for us to help you:
http://support.Microsoft.com/kb/555375You can also view the Sub articles that might help you.
Windows Media Center
http://www.Microsoft.com/Windows/Windows-Media-Center/get-started/media-library.aspx
Add media files to Windows Media Center
http://Windows.Microsoft.com/en-us/Windows7/add-media-files-to-Windows-Media-Center -
Paint or Windows Photo Gallery
I try to combine a picture of my sister with a picture of a poem beside it, how to combine the two into a single photo?
If you have the poem recorded in an image format,
the following freeware can create a side by side
Panorama.(FWIW... it's always a good idea to create a system)
Restore point before installing software or updates)Download IrfanView
http://MajorGeeks.com/IrfanView_d4253.html
(filename: iview433_setup.exe)
(uncheck if you don't want Google Chrome)Download plug-ins too...
IrfanView plugins
http://MajorGeeks.com/IrfanView_PlugIns_d4908.html
(filename: irfanview_plugins_433_setup.exe)When the program is installed... read more...
Open IrfanView and go... Image / create the Image of the Panorama...
(this will open the screen to "Create a panorama image")On the screen to "Create a panorama image"... left click on the add images"" button.
(Displays the 'Open' screen. Now, drill down to the
the folder that contains your saved Photos of veterinarians.Now... click left (highlighted), the two images, you want to join.
(you can select more than one if you hold down your Ctrl key)
The two images highlight... left click on the button 'open '.
(Or... you can add the images one at a time... which is always easier)Now, go back to the screen "Create the panorama image.
and the file names of the selected pictures need to be in the
Field "Input Images.Now with the names of two files in 'Images of entry' field...
You can left click on the button 'create Image '.(the positions left and right of these images can be swapped in)
selection of a file name and using the "mount image" / "Move."
Images down"buttons...)Now you should see a display of the combined image.
Reach... File / save as...Choose a backup location / enter a file name / choose a format...
On the left, click on the button "Save..." -
How to combine several single pdf files into a single PDF with multiple pages?
How to combine several single page pdf files into a PDF file with multiple pages?
Hi Sandra,.
You have ExportPDF subscription to Adobe not associating the files for you. It is only used to convert PDFS into different formats.
To combine PDF you could to buy the different subscription: Pack PDF
Let me know if you have any questions
Kind regards
~ Dominique
-
Catch 22 - Port Network Configurations: how to combine identifiers VLAN native with DHCP (but allow the virtual computer)
I came across a Catch 22. Maybe someone can restore the directly here. I found a "witch hunt" for sure.
It comes with the Ports of junction on the side of the switch of the ESX host network.
Context:
Ok. The Setup is a HP Blade C7000 enclosure. I try to configure ports for switching to the blades. ESX 3.5 U4 will be installed the BL460cs. Installation is preferred method: revive unattended. No problem with the syntax of Kick-Start,
I am here, it's the side network.
The problem:
I find a major complication in that the switch ports must be configured for both traffic Service Console and VMkernel, more Virtual Machine since only two NICs by blade. Not best practices, but we have only two switches Cisco 3020 inside. The two uplink physical NIC is paired in the same vSwitch. (No iSCSI does fortunately).
So the Catch 22 question is as follows:
If the id VLAN native set up on the switch port, DHCP works of course and the VMware boot loader is able to grasp a binary / packets on the network (FTP Site) and install OK. But after no installation, no communication with SC unless I set the VLAN id of the SC to '0 '. The value "4" 0 does not communication, but "40" is the VLAN native.
If id configuring VLAN native retired from the Switch port, DHCP will not work and host does not have IP address during the VMware boot process. This is as expected as traffic without label is not assigned an eligible
VLAN, so no comms.
The Port of the Switch configuration:
interface GigabitEthernet0/16
SERVERNAME description
switchport trunk encapsulation dot1q
switchport trunk vlan native 40
switchport trunk allowed vlan 40-254
switchport mode trunk
switchport nonegotiate
Speed 1000
No cdp enable
spanning tree portfast trunk
end
Summary
OK, let's summarize where things are and if possible please attach responses to their digital identity.
(1) is there a way to delete the VLAN tagging altogether side ESX host? Not only the id '0 '. The problem is with clearly with the VLAN native defined as "40". If "40" IDs specified on the Group of ports for the Service Console, no joy, no comms. If the id of '0' value, capable of ping gateway and communicate on the network.
(2) what is the problem with the definition of VLAN native as "40" when the config for the switch port is set as VLAN native "40"? Or if it was a problem? Both parameters clearly do not work together.
(3) a switch receiving a unmarked frame it will assign to the VLAN Trunk native. Ok. Trunking bases and why I need a VLAN specified on the port for DHCP native work. But it seems that since the id VLAN is set manually even as VLAN native, closed communications and no traffic as possible.
(4) executives made tag 802. 1 q VLAN native? I think that it is not and this could well be the problem. Since the id VLAN "40" is not labeled, but try to score the side host vSwitch port group.
Please let me know your thoughts, community and how in general, we are approaching 2 NIC ESX configurations.
When trunking multiple VLANs, you either have a default VLAN is nothing is tagged, or you don't. That's what the vlan native to you, it defines which VLAN would be used if no tag is visible on the packets traversing the network. For servers, if you are marking, then everything has to tag, if you're not marking at the server level, then the port must be either an access port or a VLAN native or default must be set. I also don't keep your service console the same network as your vm. Keep this isolated for the security of the network. If you isolate this VLAN, you can separate and use a single IP address for installation and one for post construction.
Or, you can provide an IP address during the build.
-KjB
VMware vExpert
-
How to combine two conditions: there is and point not null?
Hello!
I have a flash chart area I would like to show only if two conditions are true.
The first condition is the following:
There are (at least a line returns the SQL query):
And the second condition would be:select 1 from observatoire.fiche aa, observatoire.activite_faite bb where aa.fiche_id = bb.fiche_id and bb.fiche_id = aa.fiche_id AND bb.activites_id = TO_NUMBER(:P23_ACTIVITES_ID) AND TRUNC(aa.date_activite, 'YYYY') = TRUNC(TO_DATE(:P23_ANNEE, 'YYYY'), 'YYYY')
Point not null:
How to combine these two conditions in one display condition?P23_ACTIVITES_ID
Thank you.
ChristianHello
The problem is that you do-
TO_NUMBER(:P23_ACTIVITES_ID)
When you leave the value of Null return like this, you will see "null %" generally used in session state (i.e., it is not actually null). Of course 'null %' cannot be converted to a number, from which the error you see.
A simple solution would be to make your value null return value-1 or another value that is guaranteed not to be a piece of identification (and alternative is to convert the real null null % thanks to a process of App/Page etc (if you search this forum you will find a few examples on how to do this).) Another alternative is to use a DECODING to detect the '% null' etc.
Hope this helps,
John.
--------------------------------------------
Blog: http://jes.blogs.shellprompt.net
Work: http://www.apex-evangelists.com
Author of Pro Application Express: http://tinyurl.com/3gu7cd
AWARDS: Don't forget to mark correct or useful posts on the forum, not only for my answers, but for everyone! -
How to exit while loop with delay schedule?
I have a pretty heavy program that iteratively takes a series of measures from a number of channels using a variety OR-Switch and OR-DMM screws that I assembled as a result of various examples and several help pages. Each channel is sampled once during each iteration with data to be saved in a text file for later analysis, after it is imported into Excel. I added to the screen 'real time' indicators and charts to see what looks like running data.
Each iteration is performed using a While loop with a delay timer, even if a previous version, I used a timed loop. Measures for the series of channels are collected with a loop For inside the While loop. The loop For includes screws which:
1 cut the channel and wait as debounce.
2 Initializes the DMM and passes the configuration information.
3. wait for a while to make sure that the DMM is set.
4. measure.
5. close the DMM.
6 disconnect all the switches.
The terms of the election of the channels is ends in 15-20 seconds and I am currently collecting data every two minutes, so he spends "wait" time "collection". Each iteration of the loop For initializes and closes the DMM to avoid the hot switch.
Other components of the program are configuration setting controls, etc. (in front of the While loop), a "current measurement" indicator and a writing-text inside the loop file operation For, several indicators of the iteration (inside the While loop, but outside the loop For) and a bunch of operations related to the grouping and table that provide graphics of groups of time vs measures.
I don't know there are more elegant ways to perform many functions that I do and I'm not posting the VI here because I want to concentrate on what I know, it's a big problem with my program (for now!) - I can't figure out how to get out of the While loop. I tried the combinations of Boolean control, its conditions of latch and Stop / continuous if true to nothing does not.
I want a 'Stop' button that ends the While loop, at the next opportunity, but it is not working properly, I think, because the stop button does not play with good timing, because the program runs either the loop For or the time delay at the beginning of the While loop. 'Next opportunity' can mean 'Immediately', 'at the end of the next iteration of the loop,"or"at the end of the next delay schedule." I think that if I get one of these scenarios to work, I can get an any of them to work!
Help, please!
-
Combination of substring and instring in RTF - dynamic signature images url
I am unable to use a combination of substring and instring in RTF model.
I have a BUYER_LAST_NAME column, which has a Jean Dupont value. I like to shoot 'john' on this channel.
I tried to create a variable using <? xdoxslt:set_variable($_XDOCTX,_'new_name',_'')? >
So I want to do a get variable using substr and InStr.
<? xdoxslt:get_variable (substring _XDOCTX, BUYER_LAST_NAME, $(DOCUMENT_BUYER_LAST_NAME, 1, instring(BUYER_LAST_NAME,' ')-1))? >
The command above does not work as a substring and instring aren't xdoxslt operations.
I tried to do this using xdofx: <? xdofx:substr (BUYER_LAST_NAME, 1, Instr(BUYER_LAST_NAME,' ')-1)? >
The above work, but I don't know how to make a variable defined using xdofx. Please help me on this.
Published:
I want to use this field in a dynamic signature display. But I can't call substring-before command as part of the url.
URL: {(concat('${OA_MEDIA}','/purchase_order/signatures/',.//BUYER_FIRST_NAME,'_',.//BUYER_LAST_NAME,'.jpg')}
I want to change the BUYER_LAST_NAME here.
I'm working on
URL: {concat (' ${OA_MEDIA} ',' / purchase_order/signatures /',. / / DOCUMENT_BUYER_FIRST_NAME, "_",. / /, '.jpg')}
But it does not work.
->
URL: {concat (' ${OA_MEDIA} ','/ purchase_order/signatures /',. / / DOCUMENT_BUYER_FIRST_NAME, '_', substring-before(.//DOCUMENT_BUYER_LAST_NAME, ' '), '.jpg')}
who is working for me
-
Find entries with several conditions, including the comparison
Hello
I take the edition of I v6.2.7 a ride, I'm looking at the use case is the following. I have a "table" with about 100 k records defined by this object:
@Entity public class LTROW { @PrimaryKey private Integer id = null; @SecondaryKey(relate=Relationship.MANY_TO_ONE) private Integer tableId = null; @SecondaryKey(relate = Relationship.MANY_TO_ONE) private String col0 = null; @SecondaryKey(relate = Relationship.MANY_TO_ONE) private String col1 = null; @SecondaryKey(relate = Relationship.MANY_TO_ONE) private String col2 = null; @SecondaryKey(relate = Relationship.MANY_TO_ONE) private String col3 = null; @SecondaryKey(relate = Relationship.MANY_TO_ONE) private String col4 = null; @SecondaryKey(relate = Relationship.MANY_TO_ONE) private String col5 = null; @SecondaryKey(relate = Relationship.MANY_TO_ONE) private String col6 = null; @SecondaryKey(relate = Relationship.MANY_TO_ONE) private String col7 = null; private String result0 = null; private String result1 = null; private String result2 = null; private String result3 = null; private String result4 = null; // ... }
Typical research I must apply is: give me all the entries contained in tableId X where the value of co0 is equal to 7, 1112 exceeds the value of col1 and col2 value is less than 8.
I got in the definition of index for all columns defined in the class, but can't seem to understand how to combine these criteria. I looked at EntityJoin but it doesn't seem to be what I'm looking for.
Thank you!
You cannot use multiple indexes for this kind of query. Instead, create and use a single index for one of the conditions and filter on other conditions. I hear, by 'filter' select the records you want using an 'if' statement Try to choose the index that returns the smallest number of records.
See:
http://www.Oracle.com/technetwork/database/database-technologies/BerkeleyDB/performing.PDF
-mark
-
[8i] grouping with delicate conditions (follow-up)
I am posting this as a follow-up question to:
[8i] grouping with tricky conditions
This is a repeat of my version information:
Still stuck on an old database a little longer, and I'm trying out some information...
BANNER
--------------------------------------------------------------------------------
Oracle8i Enterprise Edition Release 8.1.7.2.0 - Production
PL/SQL Release 8.1.7.2.0 - Production
CORE 8.1.7.0.0-Production
AMT for HP - UX: 8.1.7.2.0 - Production Version
NLSRTL Version 3.4.1.0.0 - Production
Now for the sample data. I took an order of my real data set and cut a few columns to illustrate how the previous solution didn't find work. My real DataSet still has thousands of orders, similar to this one.
Instead of grouping all sequential steps with 'OUTPR' station, I am gathering all the sequential steps with "S9%" station, then here is the solution changed to this:CREATE TABLE test_data ( item_id CHAR(25) , ord_id CHAR(10) , step_id CHAR(4) , station CHAR(5) , act_hrs NUMBER(11,8) , q_comp NUMBER(13,4) , q_scrap NUMBER(13,4) ); INSERT INTO test_data VALUES ('abc-123','0001715683','0005','S509',0,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0010','S006',0,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0020','A501',0.85,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0026','S011',0.58,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0030','S970',0,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0040','S970',0,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0050','S003',0,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0055','S600',0,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0060','Z108',6.94,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0070','Z108',7,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0080','Z310',4.02,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0085','Z409',2.17,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0090','S500',0.85,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0095','S502',1.63,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0110','S006',0,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0112','S011',0.15,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0117','S903',0,10,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0118','S900',0,9,1); INSERT INTO test_data VALUES ('abc-123','0001715683','0119','S950',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0120','S906',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0140','S903',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0145','S950',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0150','S906',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0160','S903',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0170','S900',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0220','S902',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0230','S906',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0240','S903',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0250','S003',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0260','S006',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0270','S012',0.95,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0280','Z417',0.68,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0285','Z417',0.68,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0290','Z426',1.78,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0300','Z426',2.07,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0305','Z426',1.23,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0310','Z402',3.97,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0315','Z308',8.09,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0410','Z409',4.83,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0430','S500',3.6,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0435','S502',0.43,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0450','S002',0.35,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0460','S001',1,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0470','Z000',2.6,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0476','S011',1,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0478','S510',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0480','S903',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0490','S003',1.2,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0500','S500',1.37,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0530','B000',0.28,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0536','S011',0.65,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0538','S510',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0540','S923',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0560','S003',0,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0565','S001',0.85,0,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0570','S012',2.15,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0575','S509',0,0,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0580','B000',3.78,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0590','S011',0.27,9,0); INSERT INTO test_data VALUES ('abc-123','0001715683','0600','S510',0,9,0);
If just run the subquery to calculate grp_id, you can see that it sometimes affects the same number of group in two stages that are not side by side. For example, the two step 285 and 480 are they assigned group 32...SELECT item_id , ord_id , MIN (step_id) AS step_id , station , SUM (act_hrs) AS act_hrs , MIN (q_comp) AS q_comp , SUM (q_scrap) AS q_scrap FROM ( -- Begin in-line view to compute grp_id SELECT test_data.* , ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id ORDER BY step_id ) - ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id , CASE WHEN station LIKE 'S9%' THEN NULL ELSE step_id END ORDER BY step_id ) AS grp_id , ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id ORDER BY step_id ) AS r_num1 , ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id , CASE WHEN station LIKE 'S9%' THEN NULL ELSE step_id END ORDER BY step_id ) AS r_num2 FROM test_data ) -- End in-line view to compute grp_id GROUP BY item_id , ord_id , station , grp_id ORDER BY item_id , step_id ;
I don't know if it's because my orders have many more steps that the orders of the sample I provided, or what...
I tried this version too (by replacing all the names of the stations "S9%" by "OUTPR"):
and it shows the same problem.INSERT INTO test_data VALUES ('abc-123','0009999999','0005','S509',0,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0010','S006',0,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0020','A501',0.85,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0026','S011',0.58,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0030','OUTPR',0,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0040','OUTPR',0,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0050','S003',0,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0055','S600',0,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0060','Z108',6.94,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0070','Z108',7,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0080','Z310',4.02,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0085','Z409',2.17,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0090','S500',0.85,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0095','S502',1.63,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0110','S006',0,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0112','S011',0.15,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0117','OUTPR',0,10,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0118','OUTPR',0,9,1); INSERT INTO test_data VALUES ('abc-123','0009999999','0119','OUTPR',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0120','OUTPR',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0140','OUTPR',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0145','OUTPR',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0150','OUTPR',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0160','OUTPR',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0170','OUTPR',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0220','OUTPR',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0230','OUTPR',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0240','OUTPR',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0250','S003',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0260','S006',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0270','S012',0.95,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0280','Z417',0.68,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0285','Z417',0.68,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0290','Z426',1.78,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0300','Z426',2.07,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0305','Z426',1.23,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0310','Z402',3.97,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0315','Z308',8.09,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0410','Z409',4.83,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0430','S500',3.6,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0435','S502',0.43,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0450','S002',0.35,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0460','S001',1,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0470','Z000',2.6,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0476','S011',1,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0478','S510',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0480','OUTPR',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0490','S003',1.2,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0500','S500',1.37,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0530','B000',0.28,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0536','S011',0.65,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0538','S510',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0540','OUTPR',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0560','S003',0,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0565','S001',0.85,0,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0570','S012',2.15,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0575','S509',0,0,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0580','B000',3.78,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0590','S011',0.27,9,0); INSERT INTO test_data VALUES ('abc-123','0009999999','0600','S510',0,9,0); SELECT item_id , ord_id , MIN (step_id) AS step_id , station , SUM (act_hrs) AS act_hrs , MIN (q_comp) AS q_comp , SUM (q_scrap) AS q_scrap FROM ( -- Begin in-line view to compute grp_id SELECT test_data.* , ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id ORDER BY step_id ) - ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id , CASE WHEN station = 'OUTPR' THEN NULL ELSE step_id END ORDER BY step_id ) AS grp_id , ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id ORDER BY step_id ) AS r_num1 , ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id , CASE WHEN station = 'OUTPR' THEN NULL ELSE step_id END ORDER BY step_id ) AS r_num2 FROM test_data ) -- End in-line view to compute grp_id GROUP BY item_id , ord_id , station , grp_id ORDER BY item_id , step_id ;
Help?Hello
I'm glad that you understood the problem.
Here's a little explanation of the approach of the fixed difference. I can refer to this page later, so I will explain some things you obviously already understand, but I jump you will find helpful.
Your problem has additional feature that, according to the station, some lines can never combine in large groups. For now, we will greatly simplify the problem. In view of the CREATE TABLE statement, you have posted and these data:INSERT INTO test_data (item_id, ord_id, step_id, station) VALUES ('abc-123', '0001715683', '0010', 'Z417'); INSERT INTO test_data (item_id, ord_id, step_id, station) VALUES ('abc-123', '0001715683', '0011', 'S906'); INSERT INTO test_data (item_id, ord_id, step_id, station) VALUES ('abc-123', '0001715683', '0012', 'S906'); INSERT INTO test_data (item_id, ord_id, step_id, station) VALUES ('abc-123', '0001715683', '0140', 'S906'); INSERT INTO test_data (item_id, ord_id, step_id, station) VALUES ('abc-123', '0001715683', '0170', 'Z417'); INSERT INTO test_data (item_id, ord_id, step_id, station) VALUES ('abc-123', '0001715683', '0175', 'Z417'); INSERT INTO test_data (item_id, ord_id, step_id, station) VALUES ('abc-123', '0001715683', '0200', 'S906'); INSERT INTO test_data (item_id, ord_id, step_id, station) VALUES ('abc-123', '0001715683', '0205', 'S906');
Let's say that we want this output:
` FIRST LAST _STEP _STEP ITEM_ID ORD_ID _ID _ID STATION CNT ------- ---------- ----- ----- ------- ---- abc-123 0001715683 0010 0010 Z417 1 abc-123 0001715683 0011 0140 S906 3 abc-123 0001715683 0170 0175 Z417 2 abc-123 0001715683 0200 0205 S906 2
Where each line of output represents a contiguous set of rows with the same item_id, ord_id and station. "Contguous" is determined by step_id: lines with "0200" = step_id = step_id "0205' are contiguous in this example of data because there is no step_ids between '0200' and '0205". "
The expected results include the step_id highest and lowest in the group, and the total number of original lines of the group.GROUP BY (usually) collapses the results of a query within lines. A production line can be 1, 2, 3, or any number of lines in the original. This is obviously a problem of GROUP BY: we sometimes want several lines in the original can be combined in a line of output.
GROUP BY guess, just by looking at a row, you can tell which group it belongs. Looking at all the 2 lines, you can always know whether or not they belong to the same group. This isn't quite the case in this issue. For example, these lines
INSERT INTO test_data (item_id, ord_id, step_id, station) VALUES ('abc-123', '0001715683', '0140', 'S906'); INSERT INTO test_data (item_id, ord_id, step_id, station) VALUES ('abc-123', '0001715683', '0200', 'S906');
These 2 rows belong to the same group or not? We cannot tell. Looking at just 2 lines, what we can say is that they pourraient belonging to the same group, since they have the same item_id, ord_id and station. It is true that members of same groups will always be the same item_id, the ord_id and train station; If one of these columns differ from one line to the other, we can be sure that they belong to different groups, but if they are identical, we cannot be certain that they are in the same group, because item_id, ord_id and station only tell part of the story. A group is not just a bunch or rows that have the same item_id, ord_id and station: a group is defined as a sequence of adjacent to lines that have these columns in common. Before we can make the GROUP BY, we need to use the analytical functions to see two lines are in the same contiguous streak. Once we know that, we can store this data in a new column (which I called grp_id), and then GROUP BY all 4 columns: item_id, ord_id, station and grp_id.
First of all, let's recognize a basic difference in 3 columns in the table that will be included in the GROUP BY clause: item_id, ord_id and station.
Item_id and ord_id always identify separate worlds. There is never any point comparing lines with separate item_ids or ord_ids to the other. Different item_ids never interact; different ord_ids have nothing to do with each other. We'll call item_id and ord_id column 'separate world '. Separate planet do not touch each other.
The station is different. Sometimes, it makes sense to compare lines with different stations. For example, this problem is based on questions such as "these adjacent lines have the same station or not? We will call a "separate country" column of the station. There is certainly a difference between separate countries, but countries affect each other.The most intuitive way to identify groups of contiguous lines with the same station is to use a LAG or LEAD to look at adjacent lines. You can certainly do the job, but it happens to be a better way, using ROW_NUMBER.
Help the ROW_NUMBER, we can take the irregular you are ordering step_id and turn it into a dial of nice, regular, as shown in the column of r_num1 below:` R_ R_ GRP ITEM_ID ORD_ID STEP STATION NUM1 S906 Z417 NUM2 _ID ------- ---------- ---- ------- ---- ---- ---- ---- --- abc-123 0001715683 0010 Z417 1 1 1 0 abc-123 0001715683 0011 S906 2 1 1 1 abc-123 0001715683 0012 S906 3 2 2 1 abc-123 0001715683 0140 S906 4 3 3 1 abc-123 0001715683 0170 Z417 5 2 2 3 abc-123 0001715683 0175 Z417 6 3 3 3 abc-123 0001715683 0200 S906 7 4 4 3 abc-123 0001715683 0205 S906 8 5 5 3
We could also assign consecutive integers to the lines in each station, as shown in the two columns, I called S906 and Z417.
Notice how the r_num1 increases by 1 for each line to another.
When there is a trail of several rows of S906 consectuive (for example, step_ids ' 0011 'by '0140'), the number of s906 increases by 1 each line to another. Therefore, during the duration of a streak, the difference between r_num1 and s906 will be constant. For 3 lines of the first series, this difference is being 1. Another series of S906s contiguous started step_id = '0200 '. the difference between r_num1 and s906 for this whole series is set to 3. This difference is what I called grp_id.
There is little meaning for real numbers, and, as you have noticed, streaks for different stations can have as by chance the same grp_id. (it does not happen to be examples of that in this game of small sample data.) However, two rows have the same grp_id and station if and only if they belong to the same streak.Here is the query that produced the result immediately before:
SELECT item_id , ord_id , step_id , station , r_num1 , CASE WHEN station = 'S906' THEN r_num2 END AS s906 , CASE WHEN station = 'Z417' THEN r_num2 END AS Z417 , r_num2 , grp_id FROM ( -- Begin in-line view to compute grp_id SELECT test_data.* , ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id ORDER BY step_id ) - ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id, station ORDER BY step_id ) AS grp_id , ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id ORDER BY step_id ) AS r_num1 , ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id, station ORDER BY step_id ) AS r_num2 FROM test_data ) -- End in-line view to compute grp_id ORDER BY item_id , ord_id , step_id ;
Here are a few things to note:
All analytical ORDER BY clauses are the same. In most of the problems, there will be only an ording regime that matters.
Analytical PARTITION BY clauses include the columns of 'distinct from the planet', item_id and ord_id.
The analytical PARTITION BY clauses also among the column 'split the country', station.To get the results we want in the end, we add a GROUP BY clause from the main query. Yet once, this includes the columns of the 'separate world', column 'split the country', and the column 'fixed the difference', grp_id.
Eliminating columns that have been includied just to make the output easier to understand, we get:SELECT item_id , ord_id , MIN (step_id) AS first_step_id , MAX (step_id) AS last_step_id , station , COUNT (*) AS cnt FROM ( -- Begin in-line view to compute grp_id SELECT test_data.* , ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id ORDER BY step_id ) - ROW_NUMBER () OVER ( PARTITION BY item_id, ord_id, station ORDER BY step_id ) AS grp_id FROM test_data ) -- End in-line view to compute grp_id GROUP BY item_id , ord_id , station , grp_id ORDER BY item_id , ord_id , first_step_id ;
This prioduces the output displayed much earlier in this message.
This example shows the fixed difference indicated. Specific problem you is complicated a little what you should use an expression BOX based on station rather than the station iteself.
Maybe you are looking for
-
Why not turn my iPhone 5 c?
My iPhone 5 c suddenly stopped working, is in any way to restart?
-
HP 61 ink cartridge: How can I get a refund or a replacement cartridge 61hp
message on the printer says not compatible. printer is hp deskjet 3510 and other 61 hp cartridges work. How to MAKE a refumd or a replacement
-
What is the difference between the Mac mini and mac Pro
I will make a presentation on apple products. I need to know a simple to describe for Mac mini as well as for the mac Pro, and I think that you can use them for any monitor. I have this correct?
-
Equium M50 - How to get down to the keyboard?
How to get off the keyboard?
-
I get the following error when I shut down or restart the computer after disabling "Smart CPU for energy savings" in power management settings: Energy Management.exe - Application error The instruction at 0 x 80001700 referenced memory at 0 x 8000170