ORDER BY is not sorting correctly. Help, please!
Database:Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64 bit Production
PL/SQL Release 9.2.0.4.0 - Production
CORE Production 9.2.0.3.0
I think that the problem is related to the field of OPERATION.
Order By properly sorts if I excluded all other fields except for POINT and EXPLOITATION,
If I order by OPERATION and all other fields in my Order By clause, then the sorting is done correctly. Instead of DESC, it sorts in the order of the CSA.
FIELD INFO:
TRANSACTION is defined as Varchar2 (4)
select dtls.description
, dtls.item
, dtls.revision
, upper(dtls.serial) as serial
, dtls.wo_num
, dtls.wo_line
, dtls.operation
, '' as priorOp
, dtls.ccn
, dtls.mas_loc
, dtls.ord_qty
, dtls.compl_qty
, dtls.lab_seq
, dtls.outside
, trim(rt.oper_text) as oper_text
from
(
select unique labor.description
, labor.item
, labor.revision
, case when (trim(labor.serial) is null AND trim(cs.c_ss_serial) is not null) then cs.c_ss_serial
when (trim(cs.c_ss_serial) is null AND trim(labor.serial) is not null) then labor.serial
else labor.serial
end as serial
, labor.wo_num
, labor.wo_line
, trim(labor.operation) as operation
, labor.ccn
, labor.mas_loc
, labor.ord_qty
, labor.compl_qty
, labor.lab_seq
, labor.rtg_seq
, labor.bcr_type
, labor.outside
from
(
select trim(head.description) as description
, head.item
, head.revision
, head.serial
, head.wo_num
, head.wo_line
, head.operation
, head.ccn
, head.mas_loc
, head.ord_qty
, l.lab_complete_qty as compl_qty
, l.lab_seq
, '0001' as rtg_seq
, 'CUR' as bcr_type
, '' as outside
from (
select lab.*, sr.serial
from (
select i.description, lb.*, wo.item, wo.revision, wo.ord_qty
from (
select lt.*, d.operation
from
(
select c.wo_num, c.wo_line, max(c.lab_seq) as lab_seq
,c.ccn, c.mas_loc
from lab_tim c
where c.ccn = '1' and c.mas_loc = '1' and c.wo_num not like '%INDIRECT%' and c.lab_tran_date between to_date('3/1/2009', 'mm/dd/yyyy') and to_date('3/10/2009', 'mm/dd/yyyy') --and trim(c.wo_num) = '55302'
group by c.ccn, c.mas_loc, c.wo_num, c.wo_line
) lt,
lab_tim d
WHERE lt.ccn = d.ccn
and lt.mas_loc = d.mas_loc
and lt.wo_num = d.wo_num
and lt.wo_line = d.wo_line
and lt.lab_seq = d.lab_seq
order by lt.wo_num, lt.wo_line, d.operation asc
) lb
,wo , item i
WHERE lb.ccn = wo.ccn
and lb.mas_loc = wo.mas_loc
and lb.wo_num = wo.wo_num
and lb.wo_line = wo.wo_line
AND wo.mfg_close_date is null
AND wo.REL_DATE is not null
AND (wo.ord_qty - wo.scrap_qty - wo.complete_qty) > 0
and wo.STATUS 'C'
and wo.STATUS 'U'
and wo.item = i.item
and wo.revision = i.revision
AND ( i.pc ='2050' ) ) lab, (
select distinct i.description , wo.item,wo.revision, it.serial, wo.wo_num, wo.wo_line, wo.ccn, wo.mas_loc
from itm_wosr it, wo, item i
where it.ccn ='1' and it.mas_loc = '1' and it.wo=wo.wo_num
and wo.wo_line = wo.wo_line
and it.ccn = wo.ccn
and it.mas_loc = wo.mas_loc
and wo.status = 'I'
and i.item = wo.item AND ( i.pc ='2050' ) group by wo.ccn, wo.mas_loc, wo.item, wo.revision, wo.wo_num, wo.wo_line, it.serial,i.description )sr
WHERE lab.ccn = sr.ccn (+)
and lab.mas_loc = sr.mas_loc (+)
and lab.wo_num = sr.wo_num (+)
and lab.wo_line = sr.wo_line (+)
and lab.item = sr.item (+)
and lab.revision = sr.revision (+)
)head
, lab_tim l
WHERE head.ccn = l.ccn (+)
and head.mas_loc = l.mas_loc (+)
and head.wo_num = l.wo_num (+)
and head.wo_line = l.wo_line (+)
and head.operation = l.operation (+)
and head.lab_seq = l.lab_seq (+)
group by head.description
, head.item
, head.revision
, head.wo_num
, head.wo_line
, head.ord_qty
, head.operation
, head.ccn
, head.mas_loc
, head.serial
, l.lab_complete_qty
, l.lab_seq
) labor
,c_ss cs
WHERE labor.ccn = cs.ccn (+)
and labor.mas_loc = cs.mas_loc (+)
and labor.wo_num = cs.wo (+)
and labor.wo_line = cs.wo_line (+)
UNION ALL
-----------------------END JUST LABOR -----
-----------------------BEING OUTSIDE PROCESSING
-----
select o.*
from
( --these are parts that are still in the realm the shipping/receiving department.
Select distinct WOs. description, WOs.item, WOs.revision, WOs.serial, WOs.wo_num, WOs.wo_line
,WOs.operation, WOs.ccn, WOs.mas_loc, WOs.ord_qty, WOs.compl_qty
, '0000' as lab_seq
, '0001' as rtg_seq
, 'CUR' as bcr_type
, WOS.outside
From
( ---Max labor on these (potentially) outside parts
select shp.description, shp.item, shp.revision,max(lt.operation) as operation
,shp.wo_num, shp.wo_line, shp.serial, shp.outside, shp.ccn, shp.mas_loc
from
( ---Outside Proc Only-----Used to get the Work Orders Of Interest
select i.description, i.item, i.revision, wit.serial, wit.wo_num, wit.wo_line, max(wit.operation) as operation
, wit.ccn, wit.mas_loc, wit.ord_qty, 1 as compl_qty, '0000' as lab_seq, '0001' as rtg_seq, 'CUR' as bcr_type
, wit.outside
from (
select wo.wo_num, wo.wo_line,wo.item, wo.revision, wo.ord_qty, ot.ccn, ot.mas_loc, ot.operation
,ot.outside, ot.serial
from (
select a.*
from
(
select c.ccn, c.mas_loc, c.wo as wo_num, c.wo_line,
case
when trim(cs.operation) is null then '0'
else cs.operation
end as operation
,case
when trim(c.receiver) is null then '(Out)'
else '(Rcvd)'
end as outside
, c.c_ss_serial as serial
from c_ss c, c_shipop cs
where c.c_ss_serial is not null
and c.ccn = cs.pur_ccn
and c.mas_loc = cs.mas_loc
and trim(c.receiver) is null
and c.ccn = '1' and c.mas_loc = '1' -- and cs.dat_shipped > to_date('9/10/2008', 'mm/dd/yyyy')
and c.c_shipop_ship_num = cs.c_shipop_ship_num
and trim(cs.operation) '290.'
-- and trim(c.wo) = '55302'
--604ms
) a
order by a.wo_num, a.wo_line, a.operation
) ot
, wo
WHERE ot.ccn = '1' and ot.ccn = wo.ccn and ot.mas_loc = wo.mas_loc
and ot.wo_num = wo.wo_num
and ot.wo_line = wo.wo_line
AND wo.mfg_close_date is null AND wo.REL_DATE is not null
AND (wo.ord_qty - wo.scrap_qty - wo.complete_qty) > 0
and wo.STATUS = 'I'
order by wo.item, wo.revision, ot.operation ) wit
,item i
WHERE wit.item = i.item
and wit.revision = i.revision
and i.pc 'boogayaagaa'
AND ( i.pc ='2050' ) GROUP BY i.description, i.item, i.revision, wit.serial, wit.wo_num, wit.wo_line
, wit.ccn, wit.mas_loc, wit.ord_qty, wit.outside
order by i.item, i.revision, operation --<--slows query to 13 seconds from 607ms
--607 ms
)shp
, lab_tim lt
where shp.ccn = '1' and shp.mas_loc = '1' and shp.ccn = lt.ccn
and shp.mas_loc = lt.mas_loc
and shp.wo_num = lt.wo_num
and shp.wo_line = lt.wo_line
and shp.lab_seq < lt.lab_seq
and shp.ccn = lt.ccn
and shp.mas_loc = lt.mas_loc
and lt.wo_num not like '%INDIRECT%'
and trim(lt.operation) is not null
and trim(lt.operation) '9000' --2/27/09
and trim(lt.operation) '9050' --2/27/09
group by shp.ccn, shp.mas_loc, shp.wo_num, shp.wo_line, shp.operation, shp.item, shp.revision, shp.description
, shp.outside , shp.serial
)lab,
----*---*---*---*-------*---*---*---*--END OUTSIDE AND LABOR-----*---*---*---*-------*---*---*---*-------
----*---*---*---*-------*---*---*---*-BEING OUTSIDE NO LABOR------*---*---*---*-------*---*---*---*-------
(
--Get largest operation sent out
select i.description, i.item, i.revision, wit.serial, wit.wo_num, wit.wo_line, max(wit.operation) as operation
, wit.ccn, wit.mas_loc, wit.ord_qty, 1 as compl_qty, '0000' as lab_seq, '0001' as rtg_seq, 'CUR' as bcr_type
, wit.outside
from (
select wo.item, wo.wo_num, wo.wo_line, wo.revision, wo.ord_qty, ot.ccn, ot.mas_loc, ot.operation
,ot.outside, ot.serial
from (
select a.*
from
(
select c.ccn, c.mas_loc, c.wo as wo_num, c.wo_line,
case
when trim(cs.operation) is null then '0'
else cs.operation
end as operation
,case
when trim(c.receiver) is null then '(Out)'
else '(Rcvd)'
end as outside
, c.c_ss_serial as serial
from c_ss c, c_shipop cs
where c.c_ss_serial is not null
and c.ccn = cs.pur_ccn
and c.mas_loc = cs.mas_loc
and trim(c.receiver) is null
and c.ccn = '1' and c.mas_loc = '1' -- and cs.dat_shipped > to_date('9/10/2008', 'mm/dd/yyyy')
and c.c_shipop_ship_num = cs.c_shipop_ship_num
and trim(cs.operation) '290.'
--and trim(c.wo) = '55302'
--604ms
) a
order by a.wo_num, a.wo_line, a.operation
) ot
, wo
WHERE ot.ccn = '1' and ot.ccn = wo.ccn and ot.mas_loc = wo.mas_loc
and ot.wo_num = wo.wo_num
and ot.wo_line = wo.wo_line
AND wo.mfg_close_date is null AND wo.REL_DATE is not null
AND (wo.ord_qty - wo.scrap_qty - wo.complete_qty) > 0
and wo.STATUS = 'I' -- in process
order by wo.item, wo.revision, ot.operation ) wit
,item i
WHERE wit.item = i.item
and wit.revision = i.revision
and i.pc 'boogayaagaa'
AND ( i.pc ='2050' ) GROUP BY i.description, i.item, i.revision, wit.serial, wit.wo_num, wit.wo_line
, wit.ccn, wit.mas_loc, wit.ord_qty, wit.outside
order by i.item, i.revision, operation --<--slows query to 13 seconds from 607ms
--607 ms
) WOs -- outside items
WHERE WOs.operation > lab.operation
and WOs.ccn = lab.ccn
and WOs.mas_loc = lab.mas_loc
and WOs.wo_num = lab.wo_num
and WOs.wo_line = lab.wo_line
and WOs.serial = lab.serial
)o
order by item, revision, wo_num, wo_line
) dtls
,rtg_text rt
where dtls.ccn = rt.ccn (+)
and dtls.item = rt.item (+)
and dtls.revision = rt.revision (+)
and dtls.OPERATION = RT.OPERATION (+)
and dtls.rtg_seq = rt.rtg_seq (+)
and dtls.bcr_type = rt.bcr_type (+)
order by dtls.item, rt.operation,dtls.wo_num desc
Published by: NCR March 10, 2009 08:50
Hello
Wow, 441 lines unformatted SQL.
Why do you have several ORDER BY?
Why do you use DISTINCT and GROUP BY at the same time?
BTW,
order by dtls.item, rt.operation, dtls.wo_num desc
Simply means that dtls.wo_num is DESCENDING, rest is GROWING. That means that it is the same as
order by dtls.item ASC, rt.operation ASC, dtls.wo_num DESC
So maybe ORDER BY is sort properly after all? -Just a guess
Concerning
Peter
Published by: Peter on March 10, 2009 08:56
-Added a note on ASC/DESC
Tags: Database
Similar Questions
-
Original title: Please help, receiving the error msg in windows when you try to use I-tunes
Windows keeps giving me the message "I-tures is not installed correctly. Please re - install. "(Error Windows 7-998). I tried to re - install I-tunes several times, but the Installer seems to be difficult to remove completely and whole system crashes and I have to restart the computer. All this happened when I installed an another norton 360 version 4.0 to replace an expired norton 360 version 4.0 and I was online with them for a long time and they said that this has nothing to do with their software. I'd appreciate any help I can get, thanksHi Matthew,
It seems that the new version of Norton blocking somehow windows install to work properly.
I suggest you temporarily uninstall Norton of the machine and then try to uninstall I-tunes of the machine. You can use the Norton removal tool to accomplish the same thing.
(NOTE: please reinstall your security program once the problem is resolved.)
Once you are able to uninstall I-tunes, you can go ahead and try to reinstall the same.
Hope the helps of information.
-
The Explorer does not sort correctly
I am running Windows 7 Professional, service pack 1. Windows Explorer is not sort correctly (name). I have searched this site and other forums but couldn't find suggestions.
Hello
This is called "Intuitive" rather than the previous "literal" sort. The number 1173 is lower than 10091317, then it will appear first. First of all, this has been implemented in Windows XP.
There is an available tweak which may be closest to your preference.
How to enable or disable digital sorting in Windows Explorer:
http://www.SevenForums.com/tutorials/88153-numerical-sorting-Windows-Explorer-enable-disable.html
Alternatively, you can reverse the sort order by simply clicking on the column name header.
Let us know if it works for you.
Concerning
-
Error message: "iTunes is not installed correctly. Please reinstall iTunes.
Original title: program program program App Kompatibilitet Spel Spel Aldre Krasch Kraschar upp sig sig Hanger Hanger
I get this message: "iTunes is not installed correctly. Please reinstall iTunes.
' Error 7 (windows error 5) "when I try to run iTunes.
No matter how many times I reinstall the program nets.Trying to download iTunes again, but instead run the installer from its current location, try saving it to your hard drive and then run the configuration file.
Problem installing iTunes or QuickTime for Windows
http://support.Apple.com/kb/ht1926iTunes for Windows Vista or Windows 7: troubleshooting...
http://support.Apple.com/kb/ts1717You can try both uninstalling and reinstalling as a new user to see if that helps:
http://Windows.Microsoft.com/en-us/Windows7/create-a-user-accountIf this isn't the case, I recommend you contact Apple for assistance.
-
I bought 800 pieces of the brilliant game bee 9.99 and they have not downloaded. Help, please! Thank you Sonia Kelly.
Have you contacted the developer of the game? If they cannot / does not help, then try to contact iTunes Support: http://reportaproblem.apple.com
-
I just updated my iPad and it told me to activate it using my Apple ID. I entered my Apple ID and it will not work. Help please
There seems to be a problem, especially with older devices. And I guess that's the end of Apple since it affects both.
You can try to use iTunes to restore your device from a backup
http://support.Apple.com/kb/HT1414
Or you could wait it out and see if Apple fixes things.
-
When I turn on my new macbook air, the fan starts to make the strong nose. I got this less tha a month ago and I took good care of yhis. I'm tired of ressetting as MSC, but it did not work. Help, please
If you got less than a month ago, it is still under warranty of 90 days (I think), so take it back to the Apple Store you got OR no matter what Apple Store close to you if you bought it online.
-
Trying to connect to the PS3 online, my router is microsoft but the SSID (or our wireless network name) is not displayed! Help, please!
JamieHello
1. What is the brand and model of Microsoft Router?
If you use Microsoft MN - 700 router see link below and follow the steps.
MN-700 Base Station Configuration Guide
Download the guide and open page 3 that contains instructions for recording in the router. Page 16 has also the steps to configure the router to broadcast the SSID
If in case you use a Microsoft MN - 700 router, I suggest you to provide exact model name to get more information about the issue.
I hope this helps.
-
If I have a mask in Photoshop feather, save my work and then view in Lightroom, the mask is not good! Help, please?
This is a known bug - see workaround in this bug report in the Adobe official feedback forum: Photoshop: blur Non-destructive for the masking does not record properly more | Community customer Photoshop family. In addition, please add your vote and opinion for the bug report. even though Adobe has acknowledged the problem, they can't fix it immediately. Each vote makes it somewhat more likely that they will prioritise a fix.
-
Downloaded Photoshop Elements, I thought, made me buy my code, then said that my code was not valid. Help, please. You want to use the product.
you need a serial number and the installation file.
the former, http://helpx.adobe.com/x-productkb/global/find-serial-number.html
the latest,
Available downloadable Setup files:
- Suites and programs: CC 2015 | CC 2014 | CC | CS6 | CS5.5 | CS5 | CS4, CS4 Web Standard | CS3
- Acrobat: DC, XI, X | Suite X | 9,8 | 9 standard | 8 standard
- Captivate: 9 | 8 | 7 | 6 | 5.5, 5 | 1
- Cold Fusion: 11: 10 | 9.0.2 version 9.0.0, 9.0.1, 8.0.1, 8.0.0, 7.0, 6.1, 6.0, 5.0, 4.0
- Contribute: CS5 | CS4, CS3 | 3,2
- FrameMaker: 12, 11, 10, 9, 8, 7.2
- Lightroom: 6.4| 6| 5.7.1| 5 | 4 | 3
- Photoshop Elements: 14,13,12,11,10 | 9,8,7 win | 8 mac | 7 mac
- Premiere Elements: 14,13,12,11,10| 9, 8, 7 win | 8 mac | 7 mac
Download and installation help links Adobe
Help download and installation to Prodesigntools links can be found on the most linked pages. They are essential; especially steps 1, 2 and 3. If you click on a link that does not have these listed steps, open a second window by using the link to Lightroom 3 to see these "important Instructions".
-
LR 5, no CC, with Nikon D800, trying to tie with MacBook Pro laptop; message from non-recognition of camera. Tried to download the latest updates of LR. It runs on desktop PC but not MacBook .your help please.
What version of OS are you using? If you run El Capitan, he won't work except in the latest LR6 and CC. Libraries attach Nikon used until 2015.3 or 6.3 LR LR 5 and LR CC are incompatible with El capitan. Nikon has recently updated libraries and those that are now used in the latest versions of LR.
-
I am currently using Adobe Acrobat Pro and cannot use thumbnail images in some of my PDF files. I have not upgraded and have always the possibility to use with certain PDF files, but not all. Help, please!
Version: Adobe Acrobat 9 Pro
Windows
I found the solution:
In the PDF file, click View > Navigation panel > Pages
I had to reset panels to view the Pages again.
Thank you!
Heather Solis | Operations associate | Crown AFAM Capital, Inc.
[personal information deleted by Moderator]
-
I try to install my cs6 online ot. It is said that my code was bought, but I took it out of one of my laptops to download on it. It still does not work. Help, please
Quickly find your serial number
Activation & deactivation help
Mylenium
-
W500 - Bluetooth is missing / was not more. Help, please.
Hello. I have a cto of 4058 w500 Windows 7 Professional. With windows update running automatically and I run the system update often.
My bluetooth stopped appearing in Device Manager, networked, in the start bar, and when I try it in the start menu, nothing happens.
I went to support and downloaded again the bluetooth, ran files installation then it asks me to repair the installation of bluetooth. I say ok, and then he said: no bluetooth device was detected. Please make sure that your bluetooth device is connected correctly in order to continue the installation.
Adding new devices windows does not either. Don't know what happened, but my home system is run my bluetooth from pc to the sound and it stopped working.
Can anyone help please?
Never mind. Found the answer here: http://forums.lenovo.com/t5/W-Series-ThinkPad-Laptops/Thinkpad-W520-Win7-Bluetooth-device-not-recogn...
-
All my modules do not work! Help, please!
Today I turned on my computer and after FireFox starts, I realized that all my modules don't work at all! When I tried to check all have been properly installed and implemented market, but anyway, I didn't see their options in the Tools menu or the contextual menu (which appears when you try to save an image, CCI). My main modules (that I use constantly) are DownThemAll, ImageHostGrabber and NetVideoHunter. None works! And when I tried to "restore my last session", he has not worked as well! (It was in FireFox 11). A coupla hours ago I installed the latest version of FireFox 17th, hoping it would help me solve the problem. Nope! There is none! And by the way, now my "Add-ons" page in the Tools menu just does not open! I already scanned my computer for the bugs and viruses (with 2 specified programs) and found nothing! So I just the hell can understand what the problem is and where it could come from! Help, please! I don't want to install GoogleChrome or any other browsers and wasting my time to import links, fix bugs and various modules, etc.!
I just need to my FireFox good old (now the most recent, in fact) works correctly and that's it!
I thank you very much in advance!Thank you to everyone! But I found a solution easier - I saved just my FireFox to the base and then added settings on all necessary extensions. Everything works fine now! In any case, I understand your willingness to help: it's really comforting to feel that I'm not the only one!
Maybe you are looking for
-
Satellite A80-154 / 3-4-3 beep problem
Hello When I try to turn on the laptop, he made a series of beeps, 3-4-3 (short beeps, anyway) and the laptop is blocking down, but the Start button remains light, I need to hold down 5 seconds to turn off the laptop... In the past, I had this proble
-
PlayStation Network sucks!
I'm Livid angry. My games doesn't work on the PSN anymore and PSN decided to try to violate my constitutional right to civil action through class action. These freaks sent a 3000 + terms of service for my son 13 years and his daughter as if they woul
-
Do not open a guest account of LabVIEW
LabVIEW SP11 cannot be opened in the guest account. Tried to change settings in the system registry, but in vain.
-
Get the error code 0 X 00000015 when you try to scan
Original title: Scan problem Tried to scan HP 2100 connected directly to the USB port of the laptop. OK but previewed such access has been denied at the point of import in the process. error code 0 X 00000015 - is this a problem of security settings?
-
Strange glitch video HELP!
OK, so I was watching a video on my ROCKET and I turned it off in the middle of the clip. When I went to turn it back on, he had an image of the scene where I left off in what looked like a MUSIC - reading the display (photo Album, chronology, title