query to bring 6 rolling pay check date at any point of time
HelloWe have a date dimension dim_date, who knows the date on the calendar. I need to write a query that will always bring 6 rolling pay check dates Ant any point of time. There are 14 days between each pay cheque date and it's fall Friday. Please take as reference below and help me to write the query according to my condition. Thanks in advance.
Pay check date example:
23/03/2012
09/03/2012
24/02/2012
10/02/2012
27/01/2012
Thank you
Jay.
Hey, Jay,.
If the dates are always exactly 14 days apart, it means there is always exactly 6 of them in a period of 84 days, so you can do something like
WITH got_target_date AS
(
SELECT TO_DATE ( '03/31/2012' -- or whatever
, 'MM/DD/YYYY'
) AS taget_date
FROM dual
)
SELECT X.pay_check_date
FROM got_target_date t
JOIN table_x x ON x.pay_check_date BETWEEN target_date - 83
AND target_date
;
If the dates are not always exactly 14 days apart, you can find the last 6 on or before the deadline in this way:
WITH got_r_num AS
(
SELECT pay_check_date
, ROW_NUMBER () OVER (ORDER BY pay_check_date DESC)
AS r_num
FROM table_x
WHERE pay_check_date <= TO_DATE ( '03/31/2012' -- any target date
, 'MM/DD/YYYY'
)
)
SELECT pay_check_date
FROM got_r_num
WHERE r_num <= 6
;
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.
Tags: Database
Similar Questions
-
Equium M40X - error at startup; 0271: check date and time
Hi when I start the laptop the message:
ERROR
0271: check date and time
WARNING
0251: System CMOS checksum bad - default configuration usedPress
to resume, installation I guess it's because my CMOS battery has had? Is this a known issue with this laptop and how do you get him to replace?
Hello
It seems that your laptop is the wrong time in the CMOS (BIOS).
If you can get into the BIOS, check the date and time settings and ensure that they are correct.
It may also be a case of the CMOS battery out. In this case your laptop will tend to not keep the correct time.
In this case, you must connect the power adapter and should leave it connected for 20 to 24 hours. At the end of this period the CMOS battery must be fully charged.Good luck and best regards
-
Error 0271 check Date and time - T60
Whenever I start my T60, it is said to check date and time settings and go to the BIOS, which emits only if I press one of the buttons on the keyboard. Thinking it was a CMOS battery problem, I ordered a new one. However, the same thing happens again. I'm puzzled. How can I fix? Thank you.
Welcome to the forum!
You must scroll through "Time and date" settings in the BIOS, correct them and press F10 to save and exit.
Good luck
-
error when pass array 1 d by data in table pointer via Labview-built c++ dll
I'm trying to generate a Labview VI to a DLL and let it be invoked by vc ++, by which a 1 d array is passed. However, I can't generate the DLL when you use the data pointer to the table, which gives the error like below:
[ERROR]
Code :-2147221480
Strengthening of the DLL.
Error when compiling the DLL as a function name or a parameter is illegal. Check function and parameter names are legal C identifiers and are not inconsistent with the LabVIEW headers.
Additional information: 9 project link errors
Type Library generate error. MIDL.exe failed during the compilation of the odl file used to create the type library.
Note: The error indicates that the odl file has unknown types. This error is possible when
works with non-standard types is exported using the method qualifier exporting files in
release the configuration that have not been recompiled during the build process.The Prototype of VI define is as below
But, if I use the pointer to manage through the table, the generation is successful, error-free. I write something to call the DLL built labview, which basically reads 1000 double the data of an instrument.
#include "TestDQMaxDLL.h" #include
using namespace std; int main(int argc, char** argv) { cout << "Start testing DQMax DLL" << endl; int leng{ 1000 }; DoubleArray rawDPData = AllocateDoubleArray(leng); test_dqmax_dll(&rawDPData); cout << "Successfully invoked the DLL!" << endl; cout << "DoubleArray.len: " << (*rawDPData)->dimSize << endl; for (int i = 0; i < leng; i++) { cout << (*(rawDPData + i))->elt[0] << "\t"; if (0 == i % 10) cout << endl; } system("pause"); DeAllocateDoubleArray(&rawDPData); } But the printed results are not correct.
My questions are:
1. why cannot generate DLLS with the data of table pointer. In this case, the argument of the function is as simple as a double array.
2. for table handle pointer, when the resutls are incorrect and how to get the good ones.
Any comments would be appreciated.
BTW: I use Labview 2012 with Visual c ++ 2013 on Windows7 64 bit.
I never needed to pass a table of LabVIEW handle external code. Search this forum for posts of RolfK, it is most likely to have posted such an example. I recommend that you keep things simple and remodelling your table a table 1 d 2D before moving on to external code and manage as a 1 d table (it's just a little extra math).
Sorry I don't have a solution on why you can't build with a 1 d as a pointer of table table. If you post your project I'm happy to try to build (I'm on LabVIEW 2012, however), but as you said, it will rely on another machine, it seems more likely to be a problem with something on the specific computer where there is a problem.
-
How many layers and points can be included on any map data in map Point 2013?
How many layers and points can be included on any map data in map Point 2013?
Hello
Check with the help of MapPoint and in the MapPoint Forums.
Highway, Streets & Trips, MapPoint - Forum
http://social.Microsoft.com/forums/is/streetsandtrips/threadsMapPoint - Support
http://www.Microsoft.com/MapPoint/en-us/support.aspxSupport for MapPoint, streets & trips and Highway
http://support.Microsoft.com/ph/851I hope this helps.
Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle="">-><- mark="" twain="" said="" it="">->
-
pl/sql block, reading the reading of data from the table to a single point in time
I'm trying to figure out if several cursors in a PL/SQL block are executed inside a single Point in time, and so don't see no updates of paintings by other processes or procedures running at the same time.
The reason why I ask is I have a block of code as an initial extraction of data, with some Sanity Check before the code runs. However, if another procedure might modify the data between the two, then the mental health check is not valid. So I am essentially trying to know if there is consistency read in a PL/SQL, preventing updates to other processes to be seen.
Anyone who has an idea?
BR,
ChambazGoogle SET Transaction.
or
Follow this link
http://download-West.Oracle.com/docs/CD/B12037_01/server.101/b10759/statements_10005.htm
Kind regards
Prazy -
Question query - binding time span for Point-in-time references
I'm pulling historical data in a table for the duration of the recordings, using a reference point-in-time. I succumbed.
I threw some examples of tables and data to illustrate what I'm looking for:Create Table EmployeeInfo ( id Number(10,0), -- Employee ID Number Name VarChar2(32 Byte), -- Employee Name CurrentShift VarChar2(2 Byte) -- Current Employee Shift ); Create Table ShiftChanges ( id Number(10,0), -- Employee ID that this shift change record is for ChangeDate Date, -- Date that this Change Took Place OldShift VarChar2(2 Byte), NewShift VarChar2(2 Byte) ); Create Table TimeCard( id Number(10,0), -- Employee ID Number for this Timecard WorkDay Date, -- What Day is this Timecard for? Hours Float(63) -- Number of Hours worked. ); COMMIT;
I could do a query such as:INSERT INTO EmployeeInfo VALUES (100,'John Doe','Days') INSERT INTO EmployeeInfo VALUES (101,'Jane Doe','Days'); INSERT INTO TimeCard VALUES (100, to_date('01012010','ddmmyyyy'), 10.5); INSERT INTO TimeCard VALUES (101, to_date('01012010','ddmmyyyy'), 10); INSERT INTO TimeCard VALUES (100, to_date('02012010','ddmmyyyy'), 9); INSERT INTO TimeCard VALUES (101, to_date('02012010','ddmmyyyy'), 10.5); INSERT INTO TimeCard VALUES (100, to_date('03012010','ddmmyyyy'), 8); INSERT INTO TimeCard VALUES (101, to_date('03012010','ddmmyyyy'), 7); INSERT INTO ShiftChanges VALUES (100, to_date('02012010','ddmmyyyy'), 'Nights', 'Days'); COMMIT;
But he won't give me the history , only the current turn. Since John Doe last travel on Jan 2 nights to days, the query above would not reflect it.SELECT TC.id, EM.Name, TC.Workday, EM.CurrentShift AS Shift FROM TimeCard TC, EmployeeInfo EM WHERE (TC.ID=EM.ID(+));
I tried to join the historical table using a less - than operator. This does not work for more than one line may be returned.
The problem is that you have to parse multiple records in a table in order to obtain accurate historical data for the other.SELECT TC.id, EM.Name, TC.Workday, SC.NewShift AS Shift FROM TimeCard TC, EmployeeInfo EM, ShiftChanges SC WHERE (TC.ID=EM.ID(+)) AND (TC.ID=SC.ID(+) AND TC.WORKDAY<=SC.WORKDAY(+));
The following SQL script {color: green} works {color} - if the values are defined in advance.
However, I was unsuccessful in adapting the tables in the example I provided. If I insert the query as a subquery inline* in the statement select, it won't work, because the criteria is nested two levels down, and I can't get the values of parent in the first level.DEFINE EMPID=101; DEFINE CHGDATE=to_date('01/01/2010','dd/mm/yyyy'); SELECT SQ.Shift FROM (SELECT ShiftChanges.NewShift AS Shift, RANK() OVER (ORDER BY ShiftChanges.ChangeDate DESC) R FROM ShiftChanges WHERE ShiftChanges.id = &EMPID AND ShiftChanges.ChangeDate <= &CHGDATE ) SQ WHERE R = 1
I didn't think in a way I can do this by using a subquery nested - I keep running into this problem - how you link the data with a reference point-in-time.
Any ideas / illuminating thoughts?
Thank you
-----
{size: 8} _SELECT * FROM V$ VERSION information: _
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
PL/SQL Release 9.2.0.8.0 - Production
"CORE 9.2.0.8.0 Production."
AMT for 32-bit Windows: Version 9.2.0.8.0 - Production
NLSRTL Version 9.2.0.8.0 - Production
{size}
user10879184 re-written the original message on March 29, 2010 13:21 to take into account suggestions made by poster.On the drive home, I realized that we had to refer to the OldShift rather than NewShift to cover cases where the shift that an amendment has been made. In this case, the days before first shift change would get the current passage reported, although this was not correct. The fixed code is:
SELECT TC.id, EM.Name, TC.Workday, NVL(SC.OldShift,EM.CurrentShift) AS Shift FROM TimeCard TC, EmployeeInfo EM, (SELECT ID, Workday, ChangeDate, OldShift FROM (SELECT TC2.ID, TC2.Workday, SC2.ChangeDate, SC2.Oldshift, MIN (SC2.ChangeDate) KEEP (DENSE_RANK FIRST ORDER BY SC2.ChangeDate) OVER (PARTITION BY SC2.ID, TC2.Workday) AS Min_ChangeDate FROM ShiftChanges SC2, TimeCard TC2 WHERE TC2.Workday < SC2.ChangeDate AND TC2.ID = SC2.ID ) WHERE ChangeDate = Min_ChangeDate ) SC WHERE TC.ID=EM.ID(+) AND TC.ID=SC.ID(+) AND TC.Workday = SC.Workday(+)
It works it is not terribly effective. Perspective online joined the entire table for the time sheet to the table of ShiftChange together. I imagine that you would be restrictive forms of presence reported by a range of dates in the main query, and you do not want to apply the same filter inside the display online. Even if you filter on employee ID's
For example.
SELECT TC.id, EM.Name, TC.Workday, NVL(SC.OldShift,EM.CurrentShift) AS Shift FROM TimeCard TC, EmployeeInfo EM, (SELECT ID, Workday, ChangeDate, OldShift FROM (SELECT TC2.ID, TC2.Workday, SC2.ChangeDate, SC2.Oldshift, MIN (SC2.ChangeDate) KEEP (DENSE_RANK FIRST ORDER BY SC2.ChangeDate) OVER (PARTITION BY SC2.ID, TC2.Workday) AS Min_ChangeDate FROM ShiftChanges SC2, TimeCard TC2 WHERE TC2.Workday < SC2.ChangeDate AND TC2.ID = SC2.ID AND TC2.Workday >= SYSDATE - 7 ) WHERE ChangeDate = Min_ChangeDate ) SC WHERE TC.ID=EM.ID(+) AND TC.ID=SC.ID(+) AND TC.Workday = SC.Workday(+) AND TC.Workday >= SYSDATE - 7
-
Firefox spell check feature began to point out almost all of the words, regardless of whether the words are spelled correctly.
Tried to download and reinstall Firefox 3.6.8 but the same thing happens.
Tried different web pages to see if it was a feature of a particular Web site, but it happened while I typed this entry in a field on a Mozilla Web site page.
Such a shame, apart from the extensions topic spelling is one of my favorite features of Firefox!
Can you tell what dictionaries were causing this issue?
Only the selected dictionary has an effect.
You can see which dictionary is selected if you right click in a text box and open the submenu language.
Also make sure that [[X] "Check spelling" in the right click menu context has a tick.]
Alternatively, you can try to move on the items 'Check spelling' and the new.See http://kb.mozillazine.org/Spell_checking and How to use the spellchecker of Firefox?
-
Read a data point every time via the sound card
Hello!
I'm reading the output of an amplifier to lock that cannot be connected to my PC. So I decided to read througn my mic.
To do this, I connect channel 1 or 2 for my microphone.
However whenever I do a reading I can not simply take a while but only several points at once.
10 is the minimum number of points I can get when I put the sampling of 100 and length frequency 0.1 in the VI of its acquisition.
Any combination that translates into less than 10 points gives me an error (for example 100 sampling rate and duration 0.01).
I thought that by indexing dynamic data to acquire its VI would solve the problem, but playback is differnet from that I get when reading lock-in amplifier
through GPIB.
(I'm testing with a locking amplifier which I can via GPIB interface. So at the same time, I read with my sound card and the GPIB and compare graphs)
Any way to read a point every time? Or I'm getting something other wrong here?
Thanks for your time!
Looks like the CDA min frequency response of 10 Hz, pg 69 card technical:
http://www.hardwaresecrets.com/datasheets/ALC888_1-0.PDF
However, you can apply a known value of low voltage DC at the entrance to see if it reads properly micro. Note that microphones out low level signals, looks like the ADC full scale entry is ~1-1.5V so make sure that your entry does not exceed. You can use dividers of resistive voltage if necessary to reduce the input voltage.
-AK2DM
-
Now PC crashes with the error"SPCMDCON. "SYS at ADDRESS FBFE7617 base at FBFE5000 date: 3dbdd" any suggestions? How to protect my pc and solve my problem and frequntly turn off my pc what I would do now?
Hello
When exactly do you get this error message?
Perform a clean boot to verify if a third asks the origin of the problem.
Refer to this article for help:
http://support.Microsoft.com/kb/310353Kind regards
Afzal Taher - Microsoft technical support.
Visit our Microsoft answers feedback Forum and let us know what you think. -
You just bought a Nikon D5 XQD and I can't pictures to open in Camera Raw. Photoshop has said that it is up-to-date. Any ideas?
Please upgrade to the latest version of the bridge, also update Ps and Lr to creative cloud application.
See Adobe Bridge CC 6.2 version now available! Adobe content corner
Kind regards
Assani
-
I'm so frustrated! I have CS5 Master Collection. I want to UPGRADE to CS6 Master Collection. I want to be on the cloud! I can't find where to put up-to-date or any CONTACT to ask for help. It shouldn't be this hard. HELP Please!
See the link below:
-
Initially, I downloaded the application and was able to access all my photos by album, photostream, fb, etc.. Now, it will not go all. After you remove the application and try to download it, it says that I have to pay for it (yet) any help would be appreciated.
Sounds like a question of verification on any market that you have bought PS Touch. Have you tried contacting Google and Apple to see what they say?
-
Can you check data in a table or another, but not both in a single query?
I have a situation where I need to connect the two tables, but the data can be in another table (archive) or different records are in both but I want the last disk in two tables:
ACCOUNT
AccountID name
John Doe 123
Jane 124 Donaldson
125 Harold Douglas
MARKETER_ACCOUNT
AccountID key Marketer StartDate EndDate
1001 123 10526 8/3/2008 9/27/2009
1017 123 10987 9/28 / 2009 12/31/4712 (high date ~ that means currently with this Distributor)
1023 124 10541 03/12/2010 12/31/4712
ARCHIVES
AccountID key Marketer StartDate EndDate
1015 124 10526 8/3/2008 12/02/2010
1033 125 10987 01/01/2011 01/31/2012
If my query should return the following:
123 John Doe 10526 8/3/2008 9/27/2009
Jane Donaldson 10541 12/03/2010 31/12/124 4712 (that is the later of the two folders for this account between tables Archives and marketer_account)
125 Harold Douglas 10987 01/01/2011 01/31/2012 (it is in the archives, so get this recording)
I'm not sure how to do this in a single query. Beware, I am possibly reading several accounts at once and return to a .net collection
Open CURSOR_ACCT
Select the account ID
Of
ACCOUNT A,
MARKETER_ACCOUNT M.
R OF THE ARCHIVES
where A.AccountID = nvl ((select max (M.EndDate) of Marketer_account M2
where M2. AccountID is A.AccountID),
(select max (R.EndDate) in Archive R2
where R2. AccountID = A.AccountID)
and upper (B.SID) as a parameter. '%'
< can you do a NVL like that? probably not... I want to be able to get the MAX registration for this account on the table of MarketerACcount OR recording max for this account to off the table to Archive, but not the two >
(setting could be 'DO', so I return all names beginning with...)
Hello
So, you have a few lines in marketer_account and the other rows in the archives, but you do not want to treat all lines, as if it were a table, is it?
This sounds like a job for the UNION:
WITH union_data AS
(
SELECT StartDate, EndDate, Marketer, AccountID
OF marketer_account
UNION ALL
SELECT StartDate, EndDate, Marketer, AccountID
To archive
)
got_MaxEndDate AS
(
SELECT StartDate, EndDate, Marketer, AccountID
MAX (EndDate) ON (AccountID PARTITION) AS MaxEndDate
Of union_data
)
SELECT a.AccountID, B.SID
m.Marketer, m.StartDate, m.EndDate
One ACCOUNT
JOIN got_MaxEndDate m ON m.AccoutnID = a.AccoundID
WHERE m.EndDate = m.MaxEndDate
;
I hope that answers your question.
If this is not the case, after a CREATE TABLE and INSERT statements for your sample data.
Report when the above query is the production of incorrect results and explain, using specific examples, how to get results in these places.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).See the FAQ forum: https://forums.oracle.com/message/9362002#9362002
.
Starting with version 8, the maximum year in DATEs Oracle is 9999, not 4712.
-
Query where clause of different table without data
Hello
Oracle 11g.
I have a 'Points' table that stores information point.
In carts, users can record information on these points.
Then, the user can some carts he wants to apply to display data in a report.
Here is a minimal example (I hope I didn't too many mistakes):
If a user may for example have the following carts (according to the example above):create table points ( pt_id integer, pt_type varchar2(1), pt_accl varchar2(15), pt_class varchar2(10), pt_status varchar2(1), constraint pk_pt_id primary key(pt_id), constraint ck_pt_type check(pt_type in ('B','P', 'S', 'T')), constraint ck_pt_status check(pt_status in ('A','E')) ); create table carts( cart_id integer, cart_name varchar2(30), cart_current varchar2(1), constraint pk_cart_id primary key(cart_id), constraint ck_cart_current check(cart_current in ('Y','N')) ); create table user_selected_types( ust_id integer, ust_cart_id integer, ust_type varchar2(1), constraint pk_ust_id primary key(ust_id), constraint fk_ust_cart_id foreign key(ust_cart_id) references carts(cart_id) ); create table user_selected_accls( usa_id integer, usa_cart_id integer, usa_accl varchar2(15), constraint pk_usa_id primary key(usa_id), constraint fk_usa_cart_id foreign key(usa_cart_id) references carts(cart_id) ); create table user_selected_classes( usc_id integer, usc_cart_id integer, usc_class varchar2(10), constraint pk_usc_id primary key(usc_id), constraint fk_usc_cart_id foreign key(usc_cart_id) references carts(cart_id) ); create table user_selected_status( uss_id integer, uss_cart_id integer, uss_status varchar2(1), constraint pk_uss_id primary key(uss_id), constraint fk_uss_cart_id foreign key(uss_cart_id) references carts(cart_id) ); insert into carts values (1, 'cart_1', 'N'); insert into carts values (2, 'cart_2', 'Y'); insert into carts values (3, 'cart_3', 'Y'); insert into points values (1, 'B', 'AAA', 'AAKCM', 'A'); insert into points values (2, 'B', 'BIONH1', 'AAKCM', 'A'); insert into points values (3, 'B', 'BIONH1', 'AAKCM', 'E'); insert into points values (4, 'B', 'CTF1', 'RF45Q33', 'E'); insert into points values (5, 'T', 'L4C', 'H4V1', 'A'); insert into points values (6, 'T', 'L4C', 'H4V1', 'E'); insert into points values (7, 'S', 'BIONH1', 'RX4', 'A'); insert into points values (8, 'S', 'L4D', 'L2585', 'A'); insert into points values (9, 'S', 'L4D', 'L2585', 'E'); insert into points values (10, 'S', 'CTF1', 'CCMBQX', 'A'); insert into points values (11, 'S', 'CTF1', 'CCMBQX', 'E'); insert into points values (12, 'S', 'CTF2', 'CCMBQX', 'A'); insert into points values (13, 'S', 'CTF2', 'CCMBQX', 'E'); insert into points values (14, 'P', 'H4', 'L44W', 'A'); insert into points values (15, 'P', 'H4', 'L44W', 'E'); insert into points values (16, 'P', null, 'RK', 'E'); insert into user_selected_types values (1, 1, 'B'); insert into user_selected_types values (2, 1, 'S'); insert into user_selected_types values (3, 3, 'T'); insert into user_selected_accls values (1, 1, 'BIONH1'); insert into user_selected_accls values (2, 2, 'CTF1'); insert into user_selected_accls values (3, 2, 'CTF2'); insert into user_selected_accls values (4, 3, 'L4C'); insert into user_selected_classes values (1, 1, 'AAKCM'); insert into user_selected_status values (1, 3, 'A');
When no value is selected for an item, it must return all values.cart_1 Types : 'B', 'S' Accls : 'BIONH1' Classes : 'AAKCM' Status : [All] cart_2 Types : [All] Accls : 'CTF1', 'CTF2' Classes : [All] Status : [All] cart_3 Types : 'T' Accls : 'L4C' Classes : [All] Status : 'A'
For now, I have the following query:
It works, but the data or mixed...with t as (select cart_id d from carts where cart_current = 'Y') select * from points where ... and ( pt_type in (select ust_type from user_selected_types where ust_cart_id in (select d from T)) or not exists (select 1 from user_selected_types where ust_cart_id in (select d from T))) and ( nvl(pt_accl, '' - (null)'') in (select nvl(usa_accl, '' - (null)'') from user_selected_accls where usa_cart_id in (select d from T)) or not exists (select 1 from user_selected_accls where usa_cart_id in (select d from T))) and ( pt_class in (select usc_class from user_selected_classes where usc_cart_id in (select d from t)) or not exists (select 1 from user_selected_classes where usc_cart_id in (select d from T))) and ( pt_status in (select uss_status from user_selected_status where uss_cart_id in (select d from T)) or not exists (select 1 from user_selected_status where uss_cart_id in (select d from T)))
If the user apply cart_2 and cart_3, I don't want to for example points to accl "L4C" with status "E", forthcoming.
I just want to return the union all selected each carts.
Of course I can loop over Cart ID, PL_SQL, and build the query dynamically, as:
But imagine the user ask 500 wagons..., I've reached the limit of varchar2.for cur_c in (select cart_id d from carts where cart_current = 'Y') loop l_query := l_query || 'select ... from ... where ...' || ' union all '; end loop; l_query := substr(l_query,1,length(l_query)-11);
I can't use a CLOB that I use Oracle APEX to view the report, and he expects the query a varchar2.
I don't want to use a temporary table, as it is too slow for the application (I've tested).
You have a solution?
Thank you.
Yann.Thanks for create/insert statements - makes it much easier to help :D
Here's one way:
SQL> select 2 c.cart_id, 3 p.pt_id, 4 p.pt_type, 5 p.pt_accl, 6 p.pt_class, 7 p.pt_status 8 from carts c 9 cross join points p 10 where c.cart_current = 'Y' 11 and ( not exists(select null from user_selected_types ust where ust.ust_cart_id = c.cart_id) 12 or p.pt_type in (select ust.ust_type from user_selected_types ust where ust.ust_cart_id = c.cart_id) 13 ) 14 and ( not exists(select null from user_selected_accls usa where usa.usa_cart_id = c.cart_id) 15 or p.pt_accl in (select usa.usa_accl from user_selected_accls usa where usa.usa_cart_id = c.cart_id) 16 ) 17 and ( not exists(select null from user_selected_classes usc where usc.usc_cart_id = c.cart_id) 18 or p.pt_class in (select usc.usc_class from user_selected_classes usc where usc.usc_cart_id = c.cart_id) 19 ) 20 and ( not exists(select null from user_selected_status uss where uss.uss_cart_id = c.cart_id) 21 or p.pt_status in (select uss.uss_status from user_selected_status uss where uss.uss_cart_id = c.cart_id) 22 ) 23 order by 24 c.cart_id, 25 p.pt_id 26 ; CART_ID PT_ID P PT_ACCL PT_CLASS P ---------- ---------- - --------------- ---------- - 2 4 B CTF1 RF45Q33 E 2 10 S CTF1 CCMBQX A 2 11 S CTF1 CCMBQX E 2 12 S CTF2 CCMBQX A 2 13 S CTF2 CCMBQX E 3 5 T L4C H4V1 A 6 rows selected.
The cross join creates all the possible combinations of carriage/point. Then they are checked for 4 columns according to your rules. I think that the result is correct, if I read your question right?
If it's the most effective depends a lot on your actual data. Are the usual cases each cart sets a very small subset of points, or each cart will usually define a substantial part of the points. Carts of how are your tables? How many tables of user_selected_? How is the distribution? How many points? Indexes are available?
If the data are such that it can "pay" to build all of the possible production and "weed" down, then the foregoing can be very effective. If the data is such that the result is usually very small subset then the effectiveness may depend on the index are available.
Test and see if it works for you ;-)
If it takes hours, so if please give some information on the quantity and distribution of the data and the expected quantity and size carts etc. Then we could think in a different way...
Maybe you are looking for
-
Satellite M40: Sonic RecordNow does not recognize the carpet * CD/DVD player
HelloI have a satellite M40. The software sonic recordnow (version 7.31) not found cd/dvd writer.I check toshiba support and find a new update for Mat * a dvdram UJ 841 S. So I downloaded. But when I run it, an error message is displayed: "the target
-
What is limit RAM to W520 4282 - a34
Get contradictory docs saying that W520 supports 32 GB of RAM and 16 GB of RAM max http://support.Lenovo.com/en_US/detail.page?docid=PD015362 Thank you
-
Problem installing/running word processor
I'm trying to get up to the top of my word prosesser, but all I get is not available because LTKRN13NdII is missing can help you as I cannot get into my files
-
How do I get a free copy of the Director of the image on my computer?
It's an oficejet HP 5510 all-in-one printer. I can't find the installation disk to get this software on my newer computer and I have Office 2007
-
Reinstall Windows 7 Pro upgrade with X 17 - 24281.iso
My computer has been infected by a virus that destroyed my startup directory. I have X 17 - 24281.iso and a Windows Anytime Upgrade key valid, I'll be able to reinstall my Windows 7 Pro with the DVD that I do with X 17 - 24281.iso?