Order by on the basis of condition
I want to make order by in sql query result with condition, if data will b numaric the it should be order by on the basis of to_number else on the basis of to_char.
Edited by: Siddharth Singh on May 17, 2012 2:24 PM
Kiran wrote:
decode(LOWER(trim(col1)), UPPER(trim(col1)),to_number(trim(col1)) ,trim(col1));Did you read my reply to Ankit Rathi? Again, expression can't return values of different type. But in your case it is even worth. DECODE returns datatype based on first decoded expression. Therefore your decode will return number and as a result will fail on very first non-numeric value:
SQL> with t as (
2 select '1' col1 from dual union all
3 select '2' from dual union all
4 select 'A' from dual
5 )
6 select col1
7 from t
8 order by decode(LOWER(trim(col1)), UPPER(trim(col1)),to_number(trim(col1)) ,trim(col1));
order by decode(LOWER(trim(col1)), UPPER(trim(col1)),to_number(trim(col1)) ,trim(col1))
ERROR at line 8:
ORA-01722: invalid number
SQL> But even if you would come up with decode where first decoded expression is a string your decode wuold be useless since at the end all values would be converted back to strings. If by numeric OP means strings with digits only:
ORDER BY CASE WHEN REGEXP_LIKE(col1,'^\d+$') THEN TO_NUMBER(col1) END NULLS LAST,
col1;For example:
with t as (
select '10' col1 from dual union all
select '2' from dual union all
select '1A' from dual union all
select '1B' from dual union all
select '1C' from dual
select col1
from t
ORDER BY CASE WHEN REGEXP_LIKE(col1,'^\d+$') THEN TO_NUMBER(col1) END NULLS LAST,
col1
CO
2
10
1A
1B
1C
SQL> SY.
Similar Messages
-
Order by on the basis of last characters of the column
hi
i have this type of data in Column
ABL - Allied Corp. services (XES) - Newyork
ABL - Allied Corp. services (XES) - Chicago
SBS - Logistics - Newyork
ETC..
As the last characters are for city and i want to perform order by on the basis of city.The naming convention is "the name always contain two hiphens(-)
and the city name in the last".(means after second '-')
RegardsSQL> INSERT INTO dt_test VALUES('ABL - Allied Corp. services (XES) - Newyork');
1 row created.
SQL> INSERT INTO dt_test VALUES('ABL - Allied Corp. services (XES) - Chicago');
1 row created.
SQL> INSERT INTO dt_test VALUES('SBS - Logistics - Newyork');
1 row created.
SQL>
SQL> select
2 column_1
3 FROM
4 dt_test
5 ORDER BY
6 SUBSTR(column_1, INSTR(column_1,'-',1,2) + 2);
COLUMN_1
ABL - Allied Corp. services (XES) - Chicago
ABL - Allied Corp. services (XES) - Newyork
SBS - Logistics - Newyork -
How do I "Launch" Adobe Reader in order to accept the Terms and Conditions in order to view PDF documents? ....Somers I'm using a MAC with up to date software.
Launching is just the normal word in Apple's word for "run an app". You can launch an app from the Applications folder, or in recent versions of Mac OS using the LaunchPad (rocket icon). You can't assume all your apps appear on the dock (bottom strip), it's only the ones Apple put there or you added.
-
Production List and Sales Order list on the basis of Sales Forecast - MRP
Hi all,
One of our user wants to use MRP. what he wants is that he puts sales forecast in the system and in the basis of that sales forecast, 2 reports should be generated from system , one will tell that when production should be started to meet sales forecast for every finished good and 2nd report will tell that when sales orders should be created for raw materials to achieve sales forecast for every finished good.
Is that possible?? Please tell me in steps that how I should I proceed? what changes should be done in SPRO and in master data?
Please respond.
Best Regards,
AI.Hi AL,
As such, this is a basic functioanlity of MRP.
Once you enter a forecast & take a MRP run system proposes, when to start the production based on the production leadtime & purc.reqns for the raw materials based on the procurement lead time.
And the same can be viewed from various reports..FOr example MD04.
For this to work the MRP configurations should be valid.
Could you please confine your question to a specific query..?
Thanks & regards
Mahesh -
PM preventive PM Order confirmation on the basis of object list
Dear Experts,
In paintenance plan I have funtional location.In object list I have 5 Equipments.Now when order is generated there are 4 operations.All the operation is same to all equipments.Is it right.
Now when I am going for its confirmation,I don't know how to do the same on the basis of Equipment i.e object list.Can any one help me out with the steps involved in the same.
Regards,
Rajesh.Hi ,
1.In your case here we would do confirmation for each order operation and that will be applicable for all the eqpts in the oblect list of the order.
2. If you want to generate separate order with same operations for different eqpts then use maintenance item in the maintenance plan .Thus maintenance order gets generated for each maintenance item in the maintenance plan.The same order would be applicable for the list of eqpts in the object list of maintenance item ..
I hope this would clarify ..
regrds
pushpa -
Block Order TECO on the basis of operation User Status
Hi Experts,
I am trying to restrict the TECO of maintenance order on the basis of order operation status. I have configured the user status profile and assigned it to order operation. This user status profile have two statuses, INCL - Incomplete and another is CMPL - Complete. I have prohibited the TECO for user status INCL. But when I create an order and try to TECO, the system allows me TECO it enenif the operation user status is INCL.
Could you Pl. tell me, have I missed something in configuration?Dattatraya,
Actually you can control TECO by completion confirmation of order operation as PCNF ( partial confirmation) for operation which you have mentioned in Order. So you can set up in configuration like allow TECO only once CNF ( Full confirmation ) for all operations mentioned in Order.
For your mentioned scenario , I dont feel based on user status you can stop the TECO, anyway you can check with other experts as well.
Riyaj -
Down Payment Processing on the Basis: Document Condition
Hi all,
since Enhancement Pack 2 there is a new possibility of down payment process. The new process is not depending on billing plan instead depending on Document conditions.
With this you can also have the the final invoice delivery related. In the order you have just a new header condition AZWA (debit down payments).
Is there also a possibility to create for this new downpayment process a down payment request with financal bookings (similar to billing type FAZ) ?? The documentation doesn't give any information about this in the new downpayment process.?
Any experience would be nice??
Regards,
Norbert
Documentation for new downpayment process depending on document condition
http://help.sap.com/erp2005_ehp_03/helpdata/EN/ce/b7790d32554ae2abb5d2c4aa4e45d1/frameset.htmDear All,
Can anybody write me detailed customizing values for AZWA and AZWB condition types?
Online help is incomplete (e.g. condition class is missing, etc.) and system didn't add automatically these new condition types after business function activation.
Thanks.
Ferenc -
Running total on the basis of condition
Hi Gurus,
I am stuck with a problem which as follows:
I am having data in a table in the format
data_id data_val data_val_min Allowd_data_val
1 18510578 782 7000000
2 6103403 0 7000000
3 1244370 3 7000000
4 800000 100 7000000
5 90000 80 7000000
6 50000 100 7000000
I want a output as shown below
runn_data_val
782
6104185
6104188
6904188
6994188
6994288
The logic for the output is
if data_val si less then Allowd_data_val then we have to condider data_val_min for the running toal else we have to consider data_val.
because 18510578 > 7000000 so I have to consider 782 as output
Now 782+6103403 < 7000000 so I have to consider 782+6103403 = 6104185 as output
now 782+6103403+1244370 > 7000000 so I have to sonsider 782+6103403+3 = 6104188 as output
and so on...........
I have to get the desigred output through SQL only I can't use PL/SQL or user defined functions
Any help will be highly appreciated.
Thanks & Regardswith tab as (
select 1 data_id,18510578 data_val,782 data_val_min,7000000 Allowd_data_val from dual union all
select 2 data_id,6103403 data_val,0 data_val_min,7000000 Allowd_data_val from dual union all
select 3 data_id,1244370 data_val,3 data_val_min,7000000 Allowd_data_val from dual union all
select 4 data_id,800000 data_val,100 data_val_min,7000000 Allowd_data_val from dual union all
select 5 data_id,90000 data_val,80 data_val_min,7000000 Allowd_data_val from dual union all
select 6 data_id,50000 data_val,100 data_val_min,7000000 Allowd_data_val from dual union all
select 6 data_id,50000 data_val,100 data_val_min,7000000 Allowd_data_val from dual
--end of creating your test data
,newtab as (
select t.*,row_number() over (order by data_id) rnum from tab t
SELECT data_id,
data_val ,
newcol
FROM newtab
model
reference ref_cnt on (select count(*) cnt , 1 col from newtab)
dimension by (col) measures(cnt cnt)
main mainmodel dimension BY (rnum)
measures(0 newcol,data_id,data_val data_val,Allowd_data_val,data_val_min)
rules update iterate(10000000) until(iteration_number>=ref_cnt.cnt[1])
newcol[iteration_number+1] = nvl(newcol[iteration_number],0) +
case when nvl(newcol[iteration_number],0)+data_val[iteration_number+1]>Allowd_data_val[iteration_number+1]
then data_val_min[iteration_number+1] else data_val[iteration_number+1]
end
)May be this won't :-)
Ravi Kumar
Edited by: ravikumar.sv on Mar 15, 2010 7:30 PM
Added iterate condition -
Order rows on the basis of score
I have a table like this format:
ID
COL1
COL2
1
i am a boy
good is male
2
i am a good boy
good is male
3
i am a good girl
gender is female
Now the user will enter a keyword (in this example, 'good'). Based on that, if the keyword is found in column1, score will be given 2, and if the keyword is found in column2, score will be given 5.
And at the end, I have to display the ID column based on the score (max score at the top).
So the results should come like this:
ID
SCORE
2
5
1
7
3
2
How can I do?For example like this
with sample_table as (
select 1 id,'i am a boy' col1,'good is male' col2 from dual union all
select 2,'i am a good boy','good is male' from dual union all
select 3,'i am a good girl','gender is female' from dual union all
select 4,'goodie girl','gender is female' from dual union all
select 5,'good girl','gender is female good' from dual
select id,
CASE WHEN
case
when regexp_like(col1, '(^| )' || :keyword || '( |$)') then 2
else 0
end +
case
when regexp_like(col2, '(^| )' || :keyword || '( |$)') then 5
else 0
end = 0
THEN 10
ELSE
case
when regexp_like(col1, '(^| )' || :keyword || '( |$)') then 2
else 0
end +
case
when regexp_like(col2, '(^| )' || :keyword || '( |$)') then 5
else 0
end
END score
from sample_table
order by score desc -
Output determination with base pricing condition types
Hi folks,
got a question regarding the Output determination..
In the outptut type i.e order confirmation and change order confirmation, it is showing the the base price condition type i.e PR00.
But the client wants it to pick up the condition type material discount k004...
is it possible ? because what my understanding was that the output types typically picks the base condition type PR00.
but the client wants it to pick up this K004..
can anyone say how to do this....
thanx in advance,
sourav
IIn the Pricing procedure configuration there is a column Print, where for each condition you may specify if and how the condition should be printed. There is good documentation (F1) available on this field. Clear this field on PR00 and set to 'a' (or any other applicable value) for K004. This change will affect all the documents that are using the same pricing procedure though.
Otherwise either the output processing program or the form (both names may be found in the Output configuration) will have to be changed or, if the standard ones are being used, those will have to be copied as the custom (Z...) objects and then modified accordingly. -
Update Sales Order to enter a Manual Price Condition
Hello all,
SAP R/3 ERP
It is already created the Sales Order, Picking and Delivery (good issue is NOT created yet).
I can not continue my flow because is missing a pricing condition.
However the condition that is missing is an Header Manual Condition Price.
As we are dealing with a Header Condition and Good Issue and Billing is not created, it is possible to update the Sales Order and then enter the header manual condition .
My question is:
'--- In order to update the Sales Order to enter the header manual condition, do I need to delete the Delivery and Picking? If yes, what are the transaction de delete both of them? .
Thanks a lot,
BarbaraIn my opinion, there is no need to delete the delivery. Just add the manual pricing condition and click on update pricing button ->carry out new pricing. This will add the manual pricing in the sales order. Still if you want to delete the delivery, then first check whether the picking is done using transfer order. If so, use t.code LT15 to cancel the transfer order. If transfer order is not used, then just remove the pick quantity from delivery line items and then in t.code VL02N, enter the delivery document go to menu delivery document ->delete. This will delete the delivery document.
Regards, -
Error: One of the base documents has already been closed (-10)
I have a web service to get and set pick lists and add delivery notes via DI Server. but I have one scenario that causes the error 'Error: One of the base documents has already been closed (-10)':
i have a pick list with item A1 with a quantity of 10. I pick and delivery 3. now the pick list is closed and in the picklist creation dialog I can choose the remaining 7 of A1 for another picklist. but if I do so and then try to pick and delivery the remaining 7, I'm getting that error. The sales order, that is the base document of the pick list and the delivery, is still 'open'. so, what base document is meant here?I found the error. I tried to add the DocumentsAdditionalExpenses to the second delivery, too, and this is not possible.
-
Cost on the basis of order quantity
Can the cost be decided on the basis of order quantity ? For example when 100 pieces are taken the cost is 10 each but when 1 peice is purchased the cost is 50 each,
Similarly this should reflect when we sell the item in customer service.hi,
the scales would do that job for you. You do not need to explicitly mention a formulae at VK11 when maintaining condition records. And remember cost at sales order level has a different meaning. We use the term Cost to talk about VPRS condition. Normally the costs and prices at sales order level can be transferred to COPA for profitability analysis. We map these pricing conditions to COPA value fields for management reporting purpose.
regards
sadhu kishore -
How to find the number of idocs generated for a customer on the basis of his purchase order in a day ?
Dear Friends,
I am absolutely agree with your answer .
But my question is,
Lets say.....
One customer sending X number of purchase orders in a day , so how many IDocs generated on that specific day for that specific customer .
So, Question is , How can we find the no of sales orders(IDocs) generated for the customers on the specific day ?
Hope you all understood my requirement .
Thanks & Regards,
Aditya -
How to order CM25 profile on the basis of a field values?
Hi,
I'd like to order a capacity planning table on the basis of values (decreasing) of the field USR02, that is already present in the table. Where could I set that records must be shown in that order? I attach a screenshot to explain you better my scenario
Thank you.
AngeloHi Angelo,
Try to use t-code OPDT and define a sort criteria profile with field USR02, after that assign the sort profile into your list profile (With t-code OPD0). Hope it can help you!
Best regards
Tao
Maybe you are looking for
-
Problem with signing in to app store
Trying to get into the app store, typed in my user and everything but a message saying "does not verify device/computer" popped up.
-
How can I click to hande OVS and Search help for Web Dynpro
Once the F4 help is clicked, the event OVS of IF_WD_VALUE_HELP_FORWARD is triggered. Here I would like to change the value list of F4 help list, I implemented a class and a method that handle that event. Since event only has importing parameter, ho
-
React to a line-selection on a table-view
Hello, I show some data on a table-view and i want to show detail-information in another table-view when a user selects a row of my table-view. How can i get that done? Is there an event to catch? How can i realize that? Thanks for your help!
-
Is there no User Guide for Premiere Pro CS6?
I am a FCP7 refugee trying to decide between Avid and PP CS6. After waiting for a few weeks for it to be available, I have been lookiig through the PP CS6 Help PDF. I was surprised to see that it is not a complete reference guide documenting the feat
-
Math / array / matrix-question
Hallo everybody, first of all: it's not a indesignscripting- but general math-javascriptquestion. please be patient I've got a first (matrixlike-)array (won't change) var containers = [ 'container11', 'container12', 'container13', 'container14', 'co