Order by Characters not Numbers
Hello,
I need help with an order by for data like below:
select distinct First_Name
from Name
First_Name
12345 Test
25825 Apple
14782 Bob
1452 JamesI need to be able to sort ascending by just the characters
not the numbers but the numbers are included in field value.
select distinct First_Name
from Name
order by First_Name ascshould display this
25825 Apple
14782 Bob
1452 James
12345 Testbut it will order by numbers first
1452 James
12345 Test
14782 Bob
25825 AppleIs there any logic so the characters order by ascending
and the numbers are ignored when doing the order by?
The number will not always have a length of 5 or 3, it varies.
Thanks for reading!!
Hi,
You can ORDER BY a copy of the name that has all the digits removed, like this:
SELECT first_name
FROM name
GROUP BY first_name
ORDER BY LTRIM ( TRANSLATE ( first_name
, 'A0123456789'
, 'A'
;LTRIM removes any spaces that may occur at the beginning of the string after the digits are removed. Spaces that occur elsewhere are not touched.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using.
Edited by: Frank Kulash on Jun 16, 2011 10:37 AM
If you can't do SELECT DISTINCT and then ORDER BY something that's not in the SELECT clause, use GROUP BY instead of SELECT DISTINCT.
Similar Messages
-
Automatic form generation on creation transfer order for delivery note?
Hi,
I have to create a form that should automatically be generated on the creation of a transfer order for delivery note. How do I trigger this automatic creation of the form? And how can the transfer order number be passed to my print program?
Thx!hi christophe,
To issue the delivery output, go to transaction VL02N.
Then go to EXTRAS-> OUTPUT->HEADER->EDIT
In the Message output screen enter the relevant output type created for the delivery.
Choose the relevant medium of output.
Choose Simple Mail, in this case the field NAST-NACHA will be having a value of 7.
Specify the Partner Function; in this case it is MA -> Mail partner address
Select the Communication Method for the output type maintained.
This will take you to the SAPOFFICE screen.
Enter there the E-Mail Address to which you want to send the delivery document as PDF.
A mail will be sent to the e-mail address of the E-Mail Address specified, with the delivery output form as a PDF attachment.
hope it will help u ..
*& Report ZZ_TEST *
REPORT zz_test .
INCLUDE zz_test_top.
INCLUDE zz_test01.
FORM entry *
--> RETURN_CODE *
--> US_SCREEN *
FORM entry USING return_code us_screen.
CLEAR retcode.
xscreen = us_screen.
PERFORM processing USING us_screen.
CASE retcode.
WHEN 0.
return_code = 0.
WHEN 3.
return_code = 3.
WHEN OTHERS.
return_code = 1.
ENDCASE.
ENDFORM. "entry
*& Include ZZ_TEST_TOP *
TABLES : nast,
tnapr.
TYPES : BEGIN OF t_SOUDNAMEI1.
INCLUDE STRUCTURE SOUDNAMEI1.
TYPES : END OF t_SOUDNAMEI1.
Internal Table declarations
DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
i_tline TYPE TABLE OF tline WITH HEADER LINE,
i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
*Objects to send mail.
i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
i_lips LIKE lips OCCURS 0 WITH HEADER LINE,
i_SOUDNAMEI1 TYPE STANDARD TABLE OF t_SOUDNAMEI1.
Work Area declarations
DATA:w_objhead TYPE soli_tab,
wa_control_parameters TYPE ssfctrlop,
wa_output_options TYPE ssfcompop,
w_return TYPE ssfcrescl,
w_doc_chng TYPE sodocchgi1,
w_data TYPE sodocchgi1,
w_buffer TYPE string,"To convert from 132 to 255
wa_SOUDNAMEI1 TYPE t_SOUDNAMEI1,
Variables declarations
w_form_name TYPE rs38l_fnam,
w_len_in LIKE sood-objlen,
w_len_out LIKE sood-objlen,
w_len_outn TYPE i,
w_lines_txt TYPE i,
w_lines_bin TYPE i,
retcode TYPE sy-subrc,
xscreen TYPE c,
w_spld TYPE usr01-spld,
w_receiver TYPE SOXNA-FULLNAME,
w_OBJ_RECORD TYPE OBJ_RECORD,
w_user type sy-uname,
w_email TYPE ad_smtpadr.
Constants Declaration
CONSTANTS : c_x TYPE c VALUE 'X',
c_atrate(1) TYPE c VALUE '@'.
*& Include ZZ_TEST01 *
FORM PROCESSING *
FORM processing USING proc_screen.
SELECT * FROM lips
INTO TABLE i_lips
WHERE vbeln = nast-objky.
Call Function module to Getfunction Module name Generated by Smartform
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = tnapr-sform
IMPORTING
fm_name = w_form_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
retcode = sy-subrc.
ENDIF.
CLEAR : wa_control_parameters,
wa_output_options.
CASE nast-nacha.
WHEN '1'.
wa_control_parameters-device = 'PRINTER'.
WHEN '7'.
DATA: l_email TYPE ad_smtpadr.
wa_output_options-tdnoprev = c_x.
wa_control_parameters-getotf = c_x.
To get the default output device maintained in the
User profile
SELECT SINGLE spld FROM usr01
INTO w_spld
WHERE bname EQ nast-usnam.
IF sy-subrc EQ 0.
MOVE w_spld TO wa_output_options-tddest .
ENDIF.
wa_output_options-tdnoprev = c_x.
wa_control_parameters-getotf = c_x.
To get the email address maintained for the particular output
CALL FUNCTION 'NAST_GET_MESSAGE_OBJECT_RECV'
EXPORTING
pi_objkey = nast-tdname
IMPORTING
pe_addr = w_receiver
CHANGING
pc_objhandle = w_obj_record
EXCEPTIONS
maildata_not_readable = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF w_receiver NA c_atrate.
To retrieve the E-Mail Id in case we get the User name from NAST
CLEAR wa_soudnamei1.
REFRESH i_soudnamei1.
MOVE w_receiver TO wa_soudnamei1-fullname.
To get the user name
CALL FUNCTION 'SO_NAME_CONVERT_API1'
EXPORTING
name = wa_soudnamei1
TABLES
names = i_soudnamei1
EXCEPTIONS
user_not_exist = 1
parameter_error = 2
x_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR wa_soudnamei1.
READ TABLE i_soudnamei1 INTO wa_soudnamei1 INDEX 1.
MOVE wa_soudnamei1-sapname TO w_user.
To get the e-mail Id maintained in the user profile
CALL FUNCTION 'FTR_CORR_CHECK_EMAIL_SAP_USER'
EXPORTING
i_user = w_user
IMPORTING
e_email_address = l_email
EXCEPTIONS
mail_address = 1
determination_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
MOVE l_email TO w_receiver.
ENDIF.
MOVE w_receiver TO w_email.
ENDCASE.
wa_control_parameters-no_dialog = c_x.
wa_control_parameters-langu = nast-spras .
wa_output_options-tdteleland = nast-tland.
wa_output_options-tdtelenum = nast-telfx .
wa_output_options-tdsenddate = nast-erdat .
wa_output_options-tdsendtime = nast-eruhr .
wa_output_options-tddataset = nast-dsnam .
wa_output_options-tdsuffix1 = nast-dsuf1 .
wa_output_options-tdsuffix2 = nast-dsuf2 .
wa_output_options-tdimmed = nast-dimme .
wa_output_options-tddelete = nast-delet .
wa_output_options-tdautority = nast-tdautority.
wa_output_options-tdcovtitle = nast-tdcovtitle .
wa_output_options-tdcover = nast-tdocover .
wa_output_options-tdreceiver = nast-tdreceiver.
wa_output_options-tddivision = nast-tddivision.
wa_output_options-tdcopies = nast-anzal .
wa_output_options-tdnewid = c_x.
wa_output_options-tdarmod = nast-tdarmod.
wa_output_options-tdnoarmch = c_x.
CALL FUNCTION w_form_name
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = wa_control_parameters
output_options = wa_output_options
user_settings = ' '
IMPORTING
job_output_info = w_return
TABLES
it_lips = i_lips
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF nast-nacha EQ 7 AND sy-subrc EQ 0.
i_otf[] = w_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = w_len_in
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Convert PDF from 132 to 255.
LOOP AT i_tline.
Replacing space by ~
TRANSLATE i_tline USING ' ~'.
CONCATENATE w_buffer i_tline INTO w_buffer.
ENDLOOP.
Replacing ~ by space
TRANSLATE w_buffer USING '~ '.
DO.
i_record = w_buffer.
Appending 255 characters as a record
APPEND i_record.
SHIFT w_buffer LEFT BY 255 PLACES.
IF w_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
REFRESH: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR w_objhead.
Object with PDF.
i_objbin[] = i_record[].
DESCRIBE TABLE i_objbin LINES w_lines_bin.
Document information.
w_doc_chng-obj_name = 'Smartform'.
w_doc_chng-expiry_dat = sy-datum + 10.
CONCATENATE 'Delivery' 'Note'
INTO w_doc_chng-obj_descr.
*w_doc_chng-obj_descr = 'Smart form output'.
w_doc_chng-sensitivty = 'F'. "Functional object
w_doc_chng-doc_size = w_lines_txt * 255.
Pack to main body as RAW.
Obj. to be transported not in binary form
CLEAR i_objpack-transf_bin.
Start line of object header in transport packet
i_objpack-head_start = 1.
Number of lines of an object header in object packet
i_objpack-head_num = 0.
Start line of object contents in an object packet
i_objpack-body_start = 1.
Number of lines of the object contents in an object packet
i_objpack-body_num = w_lines_txt.
Code for document class
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
Packing as PDF.
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
i_objpack-body_num = w_lines_bin.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'Smartform'.
CONCATENATE 'Delivery' 'Note' '.pdf'
INTO i_objpack-obj_descr.
i_objpack-doc_size = w_lines_bin * 255.
APPEND i_objpack.
Document information.
CLEAR i_reclist.
e-mail receivers.
i_reclist-receiver = w_email.
i_reclist-express = 'X'.
i_reclist-rec_type = 'U'. "Internet address
APPEND i_reclist.
sending mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_chng
put_in_outbox = 'X'
TABLES
packing_list = i_objpack
object_header = w_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. "processing -
Adobe Elements Organizer Albums - Photos not numbered & cannot move photos
In Elements Alpums - Photos not numbered and cannot move photos
When you select an album, the sort by dropdown on the top left corner of the grid has one more option- Album order. Using this you may drag drop media in the grid to re-arrange.
Thanks
Andaleeb -
Open Sale Order Value (FD33) not getting diminished even after closing SO?
Hi,
Upon Executing FD33 and clicking the status view for a Customer say XYZ , and then choosing EXTRAS-Open Sale Order . Say the value of open sale orders being shown is 75000. Even after closing the open sale orders (By Selecting VA05 and Putting reason for Rejection), and then also the Open Sales Order value is not getting diminished.
What could be the reason ?
Pls help.
Regrds,
BinayakHi Binayak,
As mentioned by you, running of Credit re-org program 'RVKRED77' is the only solution for this problem and it is known problem in SAP.
Some precautions
1. Always run the program in background by scheduling a job.
2. The idle time is around midnight when no user is working on SAP.
3. Some time the job fails as some other program may be updating same tables as this program. In such cases re-schedule the job at different time.
4. You may run the program 'RVKRED88' which will simulate without actual updation of credit values.
Hope this clarifies..
Regards,
Madhu. -
Calculation of open orders and shipped not billed orders amount
Hi All,
I have a requirement to arrive at the values of Open Order and Shipped not billed .
This is an interface program and the output will be sent to a target server.
Input : Company code, Customer Code , Document date.
Output Fields are:
Customer Code
Sum of all open orders value
Sum of all shipped not billed orders value
To give an example
A Customer has 50 orders and the number of line items are 200 .
Overall order amount for 200 line items is 10,000.
70 line items have been delivered (amounting to 5,000) and
30 line items among the 70 delivered have been invoiced. (amounting to 3,000).
I need to know the best way to get to:
(1) Total "Open order" amount for the customer which is 5,000 in this example.
(2) Total "Shipped not billed" amount for the customer which is 2,000 in this example.
(3) Total "Invoiced" amount for the customer which is 3,000 in this example.
We are looking for the tables to access and the sequence of access
Since the interface is to be executed more than once in a day ,
the execution time should be optimum
Please suggest
Thanks
Venucheck table VBUK
GBSTK ne 'C' "over all processing status
and FKSTK ne 'C' "open billing orders
at header level
and
for item level check
Vbup tbale
make a join on Vbrk and VBuk in the where condition in addition to the selection criteria add the above two conditions and check the same.
once you have all the open orders enable the items and do the subtotalling and grand total on the item loop.
regards,
vijay -
Production order and planned order qty should not consider in MRP
Dear All,
i do not want to consider the previous month production order qty and plenned order qty (Nothing but WIP qty) in the current momth MRP, but the stock has to consider in MRP.
Example,
Before MRP,
material : XYZ
Stock : 1000
Prod Qty : 500 for 02.04.2008
PIR Qty : 2000 for 02.05.2008
After MRP, the requirement should be as below said,
material : XYZ
Stock : 1000
Prod Qty : 500 for 02.04.2008
PIR Qty : 2000 for 02.05.2008
Pld OrdQty : 1000 for 02.05.2008
For the above requirement ,i have done settings in the availabilty check like , for include planned order and include production order are "DO NOT TAKE IN ACCOUNT".
Even then also the planned order qty is generating for the "500" only.
please give the solution for the above said requirement.
thanx in advance
Regards
Srinivashi
MRP will always consider the prod order qty while doing nert req calculation.One thing u can do is TECo the prod orders and un MRP then it wont consider prod order qty.
The Availability check will check whether the components r avalaible or not based on ur scope of check
Reward points if useful
Amit -
Incoming orders in COPA not working if Sales Order blocked for Credit Check
Hi all,
We need to build a report showing all incoming sales order by entry date and/or change date (change of values or quantities later on). COPA allows to do this, but the problem is that COPA line item table is only updated if the sales order is released from credit check (VKM3). I am looking for a solution to be able to record sales orders in COPA even if they are still blocked for credit check. By doing that we will be able to report all sales orders entered from COPA and provide basis for commissions calculation to the business.
I have investigated possible COPA enhancements like COPA0005 but it doesn't seem to be used at the time of sales order save.
Thanks.Hello ,
Thanks for the reply
As you said , the credit check in the service order is information message "Credit check (maximum percentage for ope
exceeded)" .
If you enter and come out this message then one more message will come , i.e., "The business transaction can not be carried out" detail message - System status CNOK is active (ORD XXXXXXX).
with the above message , system will not allow to do the Service order release.
In this particular case , we have done the VKM1 for the sales order to unblock the order from credit check . But again system is checking the credit check at service order (created w.r.t sales order) . we are not able to control this .
we also suggested the solution to the customer , saying removal of credit check for service orders . But customer requires credit check to happen at both the documents. -
How to cancel an order if transaction not complete
How to cancel an order if transaction not complete
Presuming you're referring to a purchase from the iTunes Store, go here:
http://www.apple.com/support/itunes/contact/
and follow the instructions to report the issue to the iTunes Store. Refunds are not guaranteed, but iTunes support should be able to help you in one way or another.
Regards. -
Sale order no . can not be displayed in md04
HI ALL
sale order no . can not be displayed in md04
SurendraHi
What ever line items displayed in MD04 are relevent for MRP.
If yoursales order is not displayed , it is not relevent for MRP. Pl. coordinate with your SD collegue for configuration of sales order .In that pl. chk schedule line category.
Pl. chk these items.
Regards
YMREDDY -
Why some times delivery will created through vl10c even sale order stock is not available?
Hi,
why some times delivery will created through vl10c in batchmode even sale order stock is not available?
Thanks,
Kalyan.the correct english name is : Replenishment leadtime
Check with Replenishment lead time - Supply Chain Management (SCM) - SCN Wiki -
While creating the Transfer Order system is not picking Sale order stock?
Hi All,
In the B2B process the system is not picking the stock from from sale order stock while creating the transfer order? Please suggest.
Summary : Here we are creating the PR in the sale order and STO is created using the same PR to procure the materials from the WM plant to sale order plant. Since here intialy we are moving the stock to our sale order in WM plant and then picking the same. But while creating the Transfer order system is not picking the sale order stock in WM plant.
Regards.C S Javali
Check in schedule line in transaction flow whether Transfer Req /assembly is checked or not
Regards
Pradeep -
Production order status was not changed to 'CNF' after final confirmation.
Hi guru.
I experienced very special case that production order status was not changed to CNF after final confirmation.
I did final confirmation and canceled confirmation. (CNF -> REL)
And I did final confirmation again because of fixing activity quantity.
the strange thing is that production order status wasn't changed from REL to CNF.
I did confirmation again with 0 activity, thereby I solved this problem
BUT i don't know why this case happened.
Please, explain the reason.
Thanks.Hi,
As per my observation, their is not any change in the status of the order REL with confirmation CNF, instead of this, it has change from CRTD & then to TECO.
Sequence of the status of the order as below
1) CRTD MANC NMAT SETC
2) REL NMAT SETC - Changes from CRTD to REL after releasing of the order
3) REL CNF PRC CSER ERTR OPGN SETC - After confirmation, it updated after the order REL status.
Rgd,
Chetan -
Purchase Order history is not updated with Invoice number
Hello Experts ,
Please suggest some inputs/solution for my problem.
Scenarios is :
PO --> SO --> Invoice
I am creating the invoice with the medium EDI , when I click on Save button IDOC is generated with the message " IDoc 'xxxxxxxxxxxxx' was created and forwarded for transmission " and it showing the status as 03 i.e, The IDoc was sent to an R/3 System or an external program via a transactional RFC ...but the problem is if I got to the Purchase Order history Its not updated with the Invoice number.
What could be the problem , please suggest.Hi!
I'm not sure, in which process you link PO and SO. There are some different ways, which are totally different scenarios - if you need help here, describe more detailed.
Your invoice is probably only created with reference to SO, so check the invoice itself. In this case also the SO history should include the invoice.
Regards,
Christian -
How can I list the songs in an album in iTunes without having to do it one by one? Some albums are not numbered or they show 1. 1. 1. 1. 1. 1. 1.
Poor metadata needs to be corrected if the album is to display properly in iTunes. iTunes sees an "album" as any collection of tracks with the same Album title and the same Album Artist (or Artist if Album Artist isn't set). Each track of the album should have distinct Track V of W and Disc X of Y vaules. W,X,Y are optional, but X may be needed for multi disc albums.
See Gropuing tracks into albums for details.
tt2 -
LT03 transfer order for delivery note
Hi Guys,
I try to execute the transfer order for delivery note with Lt03 after saving my delivery, but i got the error message No item that are to be picked were found. Ho can i solve that?
Plase need ur help.
Thankshi
then check in OVLP whether u have checked box for u r item category
and also check the document flow it might have already picked
Maybe you are looking for
-
Change of quality notification document type
Hello guys, the SAP enables change of notificaiton type, but only if original notification has origin "General notification". Has somebody succeeded to change also notification with origin "Q1 Customer complaint", meaning Quality notification. Thanks
-
I have an 8 Gb iPod and a 16 Gb iPad. I'd like to be able to decide what not to sync to my iPod but would want on my iPad. Is there any way to do this?
-
Use "external" classes as plugins
hi everyone :-) i have an application which offers some plugins to the user. now the thing is: the plugins shouldn't be included into my JAR-file, the should be in an external folderstructure outside of the JAR. when i use the Class.forName(...)-meth
-
My IPhoto drops out for now reason
My IPhoto on my MacBook Pro keeps dropping out when I am trying to organize family pictures. How can I fix this problem or what suggestions can anyone give me to resolve my problem? Thanks
-
Next podcast starts automatically
On my new iPod nano (3rd Gen), when one podcast finishes, the next edition of that podcast starts automatically, if I have more than one edition of a podcast. On my old iPod 5G, I'd be able to choose the podcast I wished to listen to after one finish