Several Tables with where there is no
HelloIm trying to set up an insert statement and I would like to insert 3 record in the EMPLOYEE table. The three tables (USED, MEASURES, SALES) have constraints so it will check the tables on the fly to see whether the data exists already, if it does not then the insert. Is the place where there is no instruction wrighten as it should? Ive not been able to get this statement to work without error.
(* ORA-00933: SQL not correctly completed command *)
* 00933. 00000 - "not correctly completed SQL command * ')
Any input will be appreciated, thanks!
INSERT EMPLOYEES
(
EMPLOYEE_RATING,
EMPLOYEE_VALUE,
EMPLOYEE_REASON,
)
SELECT DISTINCT
EMPLOYEE_RATING,
EMPLOYEE_VALUE,
EMPLOYEE_REASON
MEASUREMENT, SALES
WHERE THE MEASURES. EMPLOYEE_ID = SALES. EMPLOYEE_ID
(WHERE there is no (select)
MEASURE_RATING,
MEASURE_VALUE,
MEASURE_REASON
the employee
WHERE USED. EMPLOYEE_ID = SALES. SALES_ID);
Try this Code is untested.
INSERT INTO employee
(
employee_rating, employee_value, employee_reason
)
SELECT DISTINCT employee_rating, employee_value, employee_reason
MEASURES, sales
WHERE measures.employee_id = sales.employee_id
AND NOT EXISTS (SELECT measure_rating, measure_value, measure_reason
The EMPLOYEE
WHERE employee.employee_id = sales.sales_id);
Alen
Tags: Database
Similar Questions
-
Removal of several tables with only loop FORALL
I need to remove the data from several tables with unique FORALL. It seems that FORALL does not support. Please let me know the alternatives to achieve this goal.
DB version: 11 GR 2
Write switchis for all instructions, one for each deletion. There is no reason why it should not work.
Compare:
Here are some things to know about FORALL:
Each FORALL statement can contain only a single DML statement. If your loop contains two updates and a deletion, then you will need to write three statements FORALL
-
Oracle 11.1.0.6 database
RHEL 5.3
Hi all
1.)
I want reorg several tables with the ETG. But because there are several tables with different indexes and column names I can not use the order by clause.
create the table reorg_HR_STAGE_EDW. SFHR_ORG_MAPPING_FILE
tablespace REORG
PCTFREE 10 pctused, initrans, maxtrans 1 255
storage)
initials pctincrease of 1 M following 0M 0
MINEXTENTS 1 maxextents unlimited
in select * from HR_STAGE_EDW. SFHR_ORG_MAPPING_FILE;
The table is going to get reorganized even without the orderby clause?
2.)
The steps I should follow are (please, correct me if I'm wrong):
-Create table with the new name in the new tablespace
-Remove the old tables
-Move converted tables to the original tablespace
Is it OK, what happens to the index?
Help, pleaseYou can also copy dependent table with dbms_redfinition. The procedure is called COPY_TABLE_DEPENDENTS. See http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_redefi.htm
ALTER table move would also be possible, but doen't it locks the table all the time?
Kind regards
-wiZ
-
return Recordset from several tables with session variables
First of all, let me start by appolgizing for the rawness of this question, but I'm really stuck... I have two tables in a database, a table name, username, password and company (user logs on to a secure site using the UN and PW creating a session MM_username variable). There are several users from different companies (IE 6 users of XYZ Corp., 20 ABC... etc.). The second table has data that is specific to each company. How to display the data in the second table so that it is specific to the user (ie: Robert of XYZ Corp. sees only specific data of XYZ Corp.)?
Thank you very much
What you would do, is to join the tables on the company name field in a query:
SELECT * FROM tbl_name LEFT JOIN tbl1.company_name ON tbl2.company_name WHERE username = MM_username;
If you need a more details or help database tables themselves you'll need post a few details anymore, but that's the gist of it.
And just to add, is that if you try to add in the session. Otherwise take your session for the company_name variable in table 1 and use it in a select query based on your session pages.
-
expdp + query option to export from several tables with the same condition
Hello
We want to export a subset of data only from databases to another. Both on AIX.
Source/testdatabase 11.2.0.3 (non partitioned tables)
Target productiion 11.2.0.3 database (separate tables)
Tables of same names of columns but diffrenet structures a partitioning index and traget so only want to import content
Each source datbaase hascolumn seq number table and want only to extract the last months of data.
want to use expdp but not sure how to make sure that all tables have the seq_num WHERE > 100 condition, if let table1: go out and have justTABLES:table1,table2... DUMPFILE=dump_dir CONTENT=data_only QUERY= table1:"WHERE seq_num >100 "
QUERY = "WHERE seq_num > 100"this condition would apply to all tables that we want."
I'm assuming that can also use impdp CONTENT = data_only?
Any ideas/thoughts?
Thank youQUERY = "WHERE seq_num > 100"this condition would apply to all tables that we want."
Yes, it will work for all tables, but ensure that all exported table must include this column.
QUERY
Default: no
Goal
Allows you to filter the data that is exported by specifying a clause of a SQL SELECT statement, which is applied to all tables in the work of export or a specific table.The query_clause is usually a WHERE clause for the selection of refined lines, but could be any SQL clause. For example, an ORDER BY clause can be used to accelerate a migration from a table in a heap in a table held in index. * If a [schema]. table_name is not provided, the query is applied to (and must be valid for) all tables in the export job.*
http://docs.Oracle.com/CD/B19306_01/server.102/b14215/dp_export.htm
-
outer join when there are several tables are involved
Could not put up the question correctly to the last channel, my problem is with the join when there are several tables are involved, this is just one example of the task that I have to carry.
Tab1 aura model id retailer_id information for all the weeks (from the first Monday) of the month of JUNE with cost and Helen
Tab1
model_id
retailer_id
sell_date
cost
Helene
1
12
June 3, 13
100
40
1
12
June 10, 13
200
20
1
12
17 June 13
300
20
1
12
24 June 13
400
20
2
12
June 3, 13
300
10
2
12
June 10, 13
200
20
2
12
17 June 13
300
20
2
12
24 June 13
400
20
Tab2:
each retailer belongs to a dealer, under the table has the same information
retailer_id
Dealer_id
12
100
13
100
14
101
15
101
16
101
Tab 3
There is a third layer where each dealership is having a garage band
Dealer_id
Dealer_group
100
1001
101
1001
102
2001
103
2001
104
3001
105
3001
Tab4:
Of this table for each model and dealer discount information for the month of June (every week)
model_id
Dealer_group
discount_date
discount
1
1001
June 3, 13
10
1
1001
June 10, 13
20
1
1001
17 June 13
10
1
1001
24 June 13
30
2
1001
June 3, 13
10
2
1001
June 10, 13
20
2
1001
17 June 13
10
2
1001
24 June 13
30
3
2001
June 3, 13
10
3
2001
June 10, 13
20
3
2001
17 June 13
10
3
2001
24 June 13
30
Master_info:
It's the main table which is the master table for model /retailer information
Model_id
retailer_id
1
12
2
12
3
12
4
12
1
13
2
13
Output
model_id
retailer_id
sell_date
cost
Helene
Final (cost-helene-discount)
1
12
June 3, 13
100
40
50
1
12
June 10, 13
200
20
160
1
12
17 June 13
300
20
270
1
12
24 June 13
400
20
350
2
12
June 3, 13
300
10
280
2
12
June 10, 13
200
20
160
2
12
17 June 13
300
20
270
2
12
24 June 13
400
20
350
3
12
June 3, 13
0
0
0
3
12
June 10, 13
0
0
0
3
12
17 June 13
0
0
0
3
12
24 June 13
0
0
0
4
12
June 3, 13
0
0
0
4
12
June 10, 13
0
0
0
4
12
17 June 13
0
0
0
4
12
24 June 13
0
0
0
1
13
June 3, 13
0
0
0
1
13
June 10, 13
0
0
0
1
13
17 June 13
0
0
0
1
13
24 June 13
0
0
0
2
13
June 3, 13
0
0
0
2
13
June 10, 13
0
0
0
2
13
17 June 13
0
0
0
1
13
24 June 13
0
0
0
For highted above records (model_id / retailer_id combination) there is no record in tab1 but they have entered in master_info then the recordings should come for all model_id/retailer_id with all the 0 values
Hello
Thanks for posting the sample data.
It is unclear what dates you want to include in the output. The following query shows how you can generate every Monday in a given range. If you only want to include the dates that are actually present in tabl1 and/or tab4, you can simplify this a bit.
WITH date_range AS
(
SELECT TRUNC (TO_DATE (' 3 June 2013', 'DD-Mon-YYYY'))
, 'IW '.
) AS first_monday
, TRUNC (TO_DATE (24 June 2013 ', 'DD-Mon-YYYY') + 6)
, 'IW '.
) AS last_monday
OF the double
)
all_mondays AS
(
First_monday SELECT + (7 * (LEVEL - 1)) AS sell_date
OF date_range
CONNECT BY LEVEL<= 1="" +="" (="" (last_monday="" -="">=>
/ 7
)
)
SELECT mi.model_id
mi.retailer_id
am.sell_date
, Cost of NVL (t1.cost, 0) AS
, NVL (t1.rebat, 0) IN the refund
, NVL (t1.cost, 0)
-(NVL (t1.rebat, 0))
+ NVL (t4.discount, 0)
) AS final
E master_info
CROSS JOIN all_mondays am
LEFT OUTER JOIN tab1 t1 ON t1.model_id = mi.model_id
AND t1.retailer_id = mi.retailer_id
AND t1.sell_date = am.sell_date
LEFT OUTER JOIN tab2 t2 ON t2.retailer_id = mi.retailer_id
LEFT OUTER JOIN tab 3 t3 ON t3.dealer_id = t2.dealer_id
LEFT OUTER JOIN tab4 t4 ON t4.model_id = t1.model_id
AND t4.dealer_group = t3.dealer_group
AND t4.discount_date = t1.sell_date
ORDER BY mi.retailer_id
mi.model_id
am.sell_date
;
The results are not exactly what said you you wanted. I suspect it's because of typos in that you posted.
-
Hello.
Is it possible to fill in the values (execute_query) several blocks where there is absolutely no relationship between the tables in the same form?
There is no relationship between the tables. All are separate tables with different columns. None of the names of columns match
& also the values of the columns do not match. I created blocks for all tables. When I click on run, only the first block of values (first picture) is filled.
other values of block did not get filled. Is it possible to fill in the values for all of the blocks where there is not relationship, or when there is no master block?
Is there something I can do for this? It is mandatory for me to put all the blocks in a single form.
Help me, please. Please do not respond.
Thank you.
Create a key-EXEQRY-trigger on the block where 'throw you' the quers. In it, put something like
GO_BLOCK ('BLOCK1');
EXECUTE_QUERY;
GO_BLOCK ('BLOCK2');
EXECUTE_QUERY;
...
-
Create table with several Collections of data control
Hello
I have a requirement about to display data in a table. It shows simple, but certain columns in the table are within a collection, and the others are in another collection. I read this chapter Creation of ADF Databound Tables - 11 g Release 1 (11.1.1.7.0), and she explains to create the table with a collection.
I have no knowledge on the model, I know just as control data, so what should I do? :
-Ask for the template designer to redraw the control of data to include a collection with all the data?
-Try to work with the actual data control? If so, how can I create the table several Collections of data control?
Plese let me know if there is another solution. I work with JDeveloper 11.1.1.7.
Thank you!
AAPDL
Hello
You can have a managed bean that e... g exposes an ArrayList of objects. This can then binds to the value property of the table. If the object sets the information of table row combination that you get multiple iterators (collections), then the table will display the joined data.
Frank
-
Unique table with several columns or several tables split?
What is the best.
A table with multiple columns inside or divided into several tables. Why?
How will the performance in the two scenarios?Hello
user13024762 wrote:
I have a table EMP that has column EMP_ID, EMP_NAME MGR_ID, MGR_NAME, SALARY, EXP_IN_MNTHS, EXP_IN_YRS... etc with multiple columnsI have the following tables
EMP-> EMP_ID, EMP_NAMEEach row in the table emp thie represents a separate employee. I guess other columns in the emp table might be birth_date, social_security_number and status (by example, 'Active', 'Leave', 'complete'). Here's what an employee has (at least) one of. If there is a one-to-many relationship between an employee and an attribute, then you probably want another table for this attribute.
BISHOP-> EMP_ID, MGR_ID, MGR_NAME
There is a one-to-many relationship between employees and managers? In other words, an employee may have 2 or more managers? If Yes, then you need another table.
If there is only a one-to-one relationship between employees and managers (in other words, if an employee is never more than 1 Manager) so why don't you just have a mgr_id column in the emp table?
Managers are also used for? (This is often the case, as in scott.emp and hr.employees.) If so, do not store their names in the EME and tables of mgr. Store name (and date of birth and other information) in the table emp only and, if you need a table of Bishop, just the emp_id and mgr_id column.SAL-> EMP_ID, SALARY
There is a one-to-many relationship between the employees and wages? In other words, an employee may have 2 or more treatments? If so, how will you use the values? Is a special treatments in some way, as it will be used more often than others? (In other words, you may have a current and past wages salary, but the last wages are rarely used.)
If you never have more than 1 salary for a given employee, why not just have a sal column in the emp table?EXP-> EMP_ID, EXP_IN_MNTHS, EXP_IN_YRS
There is a one-to-many relationship between the employees and what whether you store in this table?
etc. with more tables
What is the best based on
(1) performance and data recovery
(2) ease of use
(3) maintainabilityA one-to-many relationship requires an additional table. If an employee can have up to 3 managers, don't have mgr1, mgr2 and mgr3 columns in the emp table. Use a separate table, with up to 3 lines for the same employee, instead.
For 1-1 relationships, it is usually best to not have separate tables. -
Unable to create cache with several tables group
Hello
I need to create a group of cache with several tables, which are referential to the other.
There are 2 related tables and table 1 child...
While trying this thing, it gives me an error:
8222: multiple parent tables found
It is not possible to use several tables of root in a single cache group? Is there another way to use it?
Script, I used is:
create a cache group asynchronous writethrough TEST. CG1
of the TEST. ROOT1)
KEY PRIMARY ID VARCHAR2 (8 BYTES),
NAME VARCHAR2 (50 BYTE),
DESCRIPTION VARCHAR2 (255 BYTE),
POLICYTYPEID VARCHAR2 (7-BYTE)),
TEST. ROOT2)
PARAMTYPEID VARCHAR2 (5 BYTES) PRIMARY KEY,
PARAMETERUSAGE VARCHAR2 (1 BYTE),
NAME VARCHAR2 (25 BYTE),
DESCRIPTION VARCHAR2 (255 BYTE)),
TEST. CHILD1)
PARAMDETAILID NUMBER (20) PRIMARY KEY,.
ID VARCHAR2 (8 BYTE),
PARAMETERUSAGE VARCHAR2 (1 BYTE),
DISPLAYVALUE VARCHAR2 (255 BYTE),
OPERATORID VARCHAR2 (5 BYTE),
VENDORID NUMBER (20).
FOREIGN KEY REFERENCES TEST. ROOT1 (ID),
TEST KEY (PARAMETERUSAGE) REFERENCES STRANGERS. ROOT2 (PARAMETERUSAGE));You can't have multiple root within a group of cache tables. The requirements for tables in the group a cache are very strict; There must be only one top-level (root table) table and there may possibly be several children tables. Tables of the child should be linked through foreign keys to the root table or a child table above in the hierarchy.
The solution for your case is among the tables of root and the other root table in a separate cache group and the child table in a cache group. If you do this, you must take care of a few things:
1. you cannot define foreign keys between the tables of groups of different cache in TimesTen (keys may exist in Oracle) so the application must enforce referential integrity itself for these cases.
2. If you load data in a cache group (using LOAD the GROUP CACHE or "load we demand") and Timesten will not automatically load the corresponding data in the other group of cache (since he doesn't know the relationship). The application must load the data into the other group of cache explicitly.
There is no problem with transactional consistency when changes are pushed to Oracle. TimesTen maintains and reinforces the coherence transactional regardless of how the tables are arranged in groups cache correctly.
Chris
-
Reg: With the help of several tables of facts in the RPD!
Hi all
Can I get help with the following scenario?
We use OBIEE 11 g.
We have a report that uses 1 single fact table to retrieve data and it must be hell a lot of time to display the data in the report.
My question is is there a way to show the performance of the report if divide us the data in table 1 to 2 fact tables and the report uses them 2 made tables.
Are there other ways of finalization of the report for better performance.
Thanks for the help in advance!
Ajay.Hi Ajay,
Follow these steps for tuning;
1. try to adjust the SQL query generated first by the report, and then make the necessary changes. (Put index on the column that is required so that your query is scanning the index instead of the whole table)2. you can try to create the agg fact table and use agg navigation to improve performance. (This is to reduce the data set on which sql is triggered)
3. you can try to create partitions on the table of FACTS in the comic book, and so held the partitions are queried according to the filters.
4. in the last if all the foregoing does not resolve your query, you can try to divide the FACT table in two or more depending on your decision and then use fragmentation content in the MDB of the RPD layer if it will strike appropriate tables depending on whether you declare.
Mark Correct/utile so this can help.
Good luck
Kashi -
Update a field with different values of several tables
Hello
I have a table named AAA with 2 fields id and structure.
And then I have other 3 tables with 2 fields id1 and structure1 id2, table1 and table2, id3 and structure3 to table3 organized.2.
The number of AAA id is equal to the sum of the IDS of table1, table2, table3: #id = #id1 + id2 # + #id3).
I want to update the structure of AAA table with values as well as field:
where AAA.id = table1.id1-> AAA.structure = table1.structure1
where AAA.id = table2.id2-> AAA.structure = table2.structure2
where AAA.id = table3.id3-> AAA.structure = table3.structure3
Can someone help me?
I have Oracle11gR2.
Thank you in advance.Oops...
update AAA set structure = (select structure1 from table1 where aaa.id = table1.id1) where aaa.id in (select id1 from table1)
-
Unable to display data for the date where there is no entry in the table
Hello
I need a urgent, described below:
I have a table named as 'dirty', consisting of three columns: empno, sale_amt and sale_date.
(Please ref. The table with data script as shown below)
Now, if I run the query:
"select trunc (sale_date) sale_date, sum (sale_amt) total_sale of the sales group by order trunc (sale_date) by 1.
It then displays the data for the dates there is an entry in this table. But it displays no data for the
date in which there is no entry in this table.
If you run the Table script with data in your schema, then u will see that there is no entry for the 28th. November 2009 in
sales table. Now the above query displays data for the rest as his dates are in the table of the sale with the exception of 28. November 2009.
But I need his presence in the result of the query with the value "sale_date' as '28. November 2009 "and that of"total_sale"as
« 0 ».
Y at - there no way to get the result I need?
Please help as soon as POSSIBLE.
Thanks in advance.
Create the table script that contains data:
------------------------------------------
CREATE TABLE SALE
(
NUMBER EMPNO,
NUMBER OF SALE_AMT
DATE OF SALE_DATE
);
TOGETHER TO DEFINE
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(100, 1000, TO_DATE (DECEMBER 1, 2009 10:20:10 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(100, 1000, TO_DATE (NOVEMBER 30, 2009 10:21:04 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(100, 1000, TO_DATE (NOVEMBER 29, 2009 10:21:05 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(100, 1000, TO_DATE (NOVEMBER 26, 2009 10:21:06 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(100, 1000, TO_DATE (NOVEMBER 25, 2009 10:21:07 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(200, 5000, TO_DATE (NOVEMBER 27, 2009 10:23:06 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(200, 4000, TO_DATE (NOVEMBER 29, 2009 10:23:08 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(200, 3000, TO_DATE (NOVEMBER 24, 2009 10:23:09 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(200, 2000, TO_DATE (NOVEMBER 30, 2009 10:23:10 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(300, 7000, TO_DATE (NOVEMBER 24, 2009 10:24:19 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(300, 5000, TO_DATE (NOVEMBER 25, 2009 10:24:20 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(300, 3000, TO_DATE (NOVEMBER 27, 2009 10:24:21 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(300, 2000, TO_DATE (NOVEMBER 29, 2009 10:24:22 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into SALES
(EMPNO, SALE_AMT, SALE_DATE)
Values
(300, 1000, TO_DATE (NOVEMBER 30, 2009 10:24:22 ',' DD/MM/YYYY HH24:MI:SS'));))
COMMIT;
Any help will be necessary for me
Kind regardsWITH tab AS (SELECT TRUNC(sale_date) sale_date, SUM(sale_amt) total_sale FROM sale GROUP BY TRUNC(sale_date) ORDER BY 1 ) SELECT sale_date, NVL(total_sale,0) total_sale FROM tab model REFERENCE refmodel ON (SELECT 1 indx, MAX(sale_date)-MIN(sale_date) AS daysdiff , MIN(sale_date) minsaledate FROM tab) dimension BY (indx) measures(daysdiff,minsaledate) main main_model dimension BY (sale_date) measures(total_sale) RULES upsert SEQUENTIAL ORDER ITERATE(1000) until (iteration_number>refmodel.daysdiff[1]-1) ( total_sale[refmodel.minsaledate[1]+iteration_number]=total_sale[cv()] ) ORDER BY sale_date
using a clause type
Ravi Kumar
-
I have a table advanced with more or less 60 columns and the table is larger than the header image. How can I align the table with the advanced table?
Thank you.
Published by: Vieira on 1.01 giu-3-2010I don't think that this is possible.
what you can do, is that you can fix the scroll bar horizontal to your table, this way that your condition is possible. Please visit the Blog of Mukul to fix scrollbars at the table.
Kind regards
Out Sharma -
Hello
We are working on a data warehousing project and wonder how do to join several tables that each are versioned separately (type SCD 2 with a valid and valid to date).
Because for example, we get our client from a single source of information (id customer, name, etc.) and the information on the rate of customer from another source. The sources are different, we have the separate tables for them and each of them gets versioned independently.
Here's my customer table (with its own valid and valuable to the columns).
ID Name of the customer Valid from Valid until the 1 CitiBank 1 JANUARY 14 JANUARY 1, 15 1 New CitiBank 2 JANUARY 15 FEBRUARY 1, 15 1 Latest CitiBank 2 FEBRUARY 15 APRIL 1, 15 And similarly the Client side ID and rating information.
ID Note Valid from Valid until the 1 Platinum 1 JANUARY 14 FEBRUARY 1, 14 1 Premium FEBRUARY 1, 14 1ST MARCH 15 I want to merge the two tables above and present information at a glance. I have some difficulty to determine validates the valid columns.
ID Name of the customer Note Valid from (Calculated) Valid until the (calculated) 1 CitiBank Platinum 1 JANUARY 14 FEBRUARY 1, 14 1 CitiBank Premium FEBRUARY 1, 14 JANUARY 1, 15 1 New CitiBank Premium 2 JANUARY 15 FEBRUARY 1, 15 1 Latest CitiBank Premium 2 FEBRUARY 15 1ST MARCH 15 And it's the query I used to get the above result:
SELECT client. id ,
customer . name ,
CRM . level ,
Greatest (client. vld_fm , crm. vld_fm ),
Least (client. vld_to , crm. vld_to )
DE client client,
client_rating crm
OÙ client. id = crm. id
AND ( client. vld_fm <= crm. vld_fm
AND client. vld_fm <= crm. vld_to
AND client. vld_fm >= crm. vld_fm
AND client. vld_fm >= crm. vld_to )
OR ( client. vld_fm BETWEEN crm. vld_fm AND crm. vld_to )
OR ( client. vld_to BETWEEN crm. vld_fm AND crm. vld_to );
The problem is we have several data sources (and each with its own versions) and joins become so very very complex. Is there a better way to write the query?Or maybe a better way to design our tables?
Thanks for your help.
Anand
Hello
you only need ranges that overlap to join.
Re: How do to sql query in a loop
Is a simpler way to test if the x_start to x_stop range comes into conflict with the range of y_start to y_stop
WHERE x_start <= y_stop AND y_start <= x_stop
In other words, two overlapping if and only if everyone will start before the other ends one. If this is not obvious (and it was certainly not clear to me when I heard it), then look at it this way: two ranges are not overlapping if and only if one of them starts after the end of the other.
Concerning
Marcus
Maybe you are looking for
-
G10: How to get S-Video In to work outside Windows MCE
Hello We know how get s-video in a qosmio G10 working beside windows MCE, I can't make it work with Windows Movie Maker, it just says: the material is begin used by other software, but even with just the defult running process, I can't make it work?
-
Hello I just bought an A80 154 yesterday and found out that the cooling fan is really noisy and annoying. It starts and stops at intervals of 4 to 6 minutes.Any of you have experience with this issue or my laptop has a problem because I can still Exc
-
WiFi is so screwed on Satellite M45-S265
Before using a recovery disk, I would like to see if I can solve the problem of WiFi with this machine M45-S265. Now WiFi is so screwed with this machine I can't Wireless at all.Fortunately the Ethernet works fine so it's on the net. Then, how they "
-
Error using an executable file and Excel 97
Hello I have a program that writes a file samples periodically (a specific) Excel, the program works fine when I run LabVIEW, but when I try to do the same thing with an executable built with report generation tool it opens for awhile without any Exc
-
How to disable the Windows account opening screen that is displayed when the computer is turned on? He used to go directly to my office, but something has changed and I don't know how to switch back.