To split a table as two tables with equal no of records
Hi Everyone,
I have a table with size of 100000 records which is reterieved from different tables thats why idx is not in a sequential order. for example
idx
1
5
100 and so on
i want to create two different tables with same number of records but i dont want any duplicate records. Please anyone can help how can i get it.
Best Regards,
Please check the following script - hope that will help you --
SQL>
SQL> set serveroutput on
SQL>
SQL>
SQL> create table test_vaneeza
2 as
3 (
4 select 1 idx,'55 Mary Road' address from dual
5 union all
6 select 2, '10 Glenhuntly Road' from dual
7 union all
8 select 3, '5 Terrace' from dual
9 union all
10 select 100, '1212 Dandenong Road' from dual
11 union all
12 select 1000, '12 Liverpool Street' from dual
13 );
Table created.
SQL>
SQL>
SQL> set lin 1000
SQL>
SQL> select * from test_vaneeza;
IDX ADDRESS
1 55 Mary Road
2 10 Glenhuntly Road
3 5 Terrace
100 1212 Dandenong Road
1000 12 Liverpool Street
SQL>
SQL>
SQL> drop table gghh;
Table dropped.
SQL>
SQL>
SQL> create table gghh(a number(10),
2 b varchar2(100));
Table created.
SQL>
SQL>
SQL> drop table ggyy;
Table dropped.
SQL>
SQL>
SQL> create table ggyy(c number(10),
2 d varchar2(100));
Table created.
SQL>
SQL>
SQL> select count(*) from ggyy;
COUNT(*)
0
SQL>
SQL>
SQL> select count(*) from gghh;
COUNT(*)
0
SQL>
SQL> insert all
2 when rownum<=(select count(distinct idx) from test_vaneeza)/2
3 then
4 into gghh
5 else
6 into ggyy
7 select distinct idx,address
8 from test_vaneeza;
5 rows created.
SQL>
SQL>
SQL> commit;
Commit complete.
SQL>
SQL>
SQL> select count(*) from ggyy;
COUNT(*)
3
SQL>
SQL>
SQL> select count(*) from gghh;
COUNT(*)
2
SQL>
SQL>
SQL> select * from ggyy;
C D
3 5 Terrace
100 1212 Dandenong Road
1000 12 Liverpool Street
SQL>
SQL>
SQL> select * from gghh;
A B
1 55 Mary Road
2 10 Glenhuntly Road
SQL> Regards.
Satyaki De.
Similar Messages
-
SLT - Splitting one source table into two tables in the destination
Hi,
I am wondering if we can split content of one source table into two different tables in the destination (HANA DB in my case) with SLT based on the codified mapping rules?
We have the VBAK table in ERP which has the header information about various business objects (quote, sales order, invoice, outbound delivery to name a few). I want this to be replicated into tables specific to business object (like VBAK_QUOT, VBAK_SO, VBAK_INV, etc) based on document type column.
There is one way to do it as far as i know - have multiple configurations and replicate to different schema. But we might have to be content with 4 different config at the max.
Any help here will be highly appreciated
Regards,
SeshPlease take a look at these links related to your query.
http://stackoverflow.com/questions/5145637/querying-data-by-joining-two-tables-in-two-database-on-different-servers
http://stackoverflow.com/questions/7037228/joining-two-tables-together-in-one-database -
Help! about insert into one table from two tables'data?
hi,all friends!
i have a question:
i have two table as like this:
table_one(id,ipaddr,col1,col2) primary key(id,ipaddr)
table_two(id,ipaddr,col1,col3,col4) primary key(id,ipaddr)
about table_one and table_two,it's columns may change execept id and ipaddr,
how can i insert the data of table_one and table_two into table_three,the columns of table_three may change with the columns of table_one and table_two
table_three may dynamic create,but it's primary key is (id,ipaddr)
thanks!
pls help!
any suggestion welcome!insert into table_3
(id, ipaddr, col1, col2, col3, col4)
select t1.id, t1.ipaddr, t1.col1, t1.col2, t2.col3, t2.col4
from table_1 t1, table_2 t2
where t2.id = t1.id
and t2.ipaddr = t1.ipaddr; -
To find difference in table in two table
Hi,
I have a table 'A' and table 'A_repository'. Both have same column.Only difference is that table A has column ID as primary key and there is no primary or foreign key table A_repository.
In table A, for ID=1 has data. Also for table A_repository, ID=1 has data but data in few columns in table A_repository is different from table A for ID=1.
How can I know which column has different data for above senario and what is the different data( means what is data in that column for both the table).
Please give some idea.
Thanks,
ChandruCheck Comparing the Contents of Two Tables in Ask Tom: On Injecting and Comparing to find out differring rows efficiently.
Regards
Etbin -
Enter Data from one table to two tables
Hi
I have three table one is master sale_order another is sale_order_detail(detail table) and the thirs is external table
what i want the data from extenal table to my master and detail
What i did for this i create a cursor and enter the data in master but what i need in detail i am able to insert but i am not able to understand how i will insert ID in detai my cursor and table codes are given below
sale_order;
Name Null? Type
ID NUMBER
SALE_ORDER_NO VARCHAR2(50)
ORDER_DATE DATE
PARTY_NAME VARCHAR2(100)
DEL_DATE DATE
COMMENT1 VARCHAR2(200)
desc sale_order_detail;
Name Null? Type
ID NUMBER
PROD_ID VARCHAR2(20)
STYLE VARCHAR2(100)
COLOR VARCHAR2(20)
XS NUMBER
S NUMBER
M NUMBER
L NUMBER
XL NUMBER
PCS NUMBER
TOTAL_QTY NUMBER
COMMENTS VARCHAR2(100)
SQL> desc po_pending_csv;
Name Null? Type
P_O_NO VARCHAR2(20)
PARTY_NAME VARCHAR2(120)
PROD_CODE VARCHAR2(20)
STYLE_NAME VARCHAR2(120)
COLOR VARCHAR2(25)
XS VARCHAR2(25)
S VARCHAR2(25)
M VARCHAR2(25)
L VARCHAR2(25)
XL VARCHAR2(25)
PCS VARCHAR2(25)
COMMENTS VARCHAR2(100)
COMMENT1
DECLARE
v_p_o_no sale_oder.sale_order_no%type;
v_party_name sale_order.party_name%type;
CURSOR po_cursor IS
SELECT DISTINCT(p_o_no),party_name FROM po_pending_csv;
BEGIN
OPEN po_cursor;
LOOP
FETCH po_cursor INTO v_p_o_no,v_party_name;
EXIT WHEN po_cursor%NOTFOUND;
INSERT INTO sale_order (id,sale_order_no,party_name,order_date)
VALUES (sale_order_id_seq.nextval,v_p_o_no,v_party_name,sysdate);
END LOOP;
CLOSE po_cursor;
END;
DECLARE
CURSOR c1 IS
SELECT id from sale_order;
v_id sale_orderdetail.id%TYPE;
v_p_o_no sale_oder_detail.p_o_no%TYPE;
v_prod_code sale_oder_detail.prod_id%TYPE;
v_style_name sale_oder_detail.style%TYPE;
v_color sale_oder_detail.color%TYPE;
v_xs sale_oder_detail.xs%TYPE;
v_s sale_oder_detail.s%TYPE;
v_m sale_oder_detail.m%TYPE;
v_l sale_oder_detail.l%TYPE;
v_xl sale_oder_detail.xl%TYPE;
v_pcs sale_oder_detail.pcs%TYPE;
v_comments sale_oder_detail.comments%TYPE;
CURSOR po_cursor_detail IS
SELECT p_o_no,prod_code,style_name,color,xs,s,m,l,xl,pcs,comments
FROM po_pending_csv;
BEGIN
OPEN po_cursor_detal;
OPEN c1;
LOOP
FETCH po_cursor_detail INTO v_p_o_no,v_prod_code,
v_style_name,v_color,v_xs,v_s,v_m,v_l,v_xl,v_pcs,v_comments;
FETCH c1 INTO v_id;
EXIT WHEN po_cursor_detail%NOTFOUND;
EXIT WHEN c1%NOTFOUND;
INSERT INTO sale_order_detail(id,prod_id,style,color,xs,s,m,l,xl,pcs,
total_qty,comments)
VALUES (v_id,v_prod_id,v_style,v_color,v_xs.v_s,v_m,v_l,v_xl,v_pcs,
v_xs+v_s+v_m+v_l+v_xl,v_comments);
END LOOP;
CLOSE po_cursor_detail;
CLOSE c1;
END;
plesae help me
thanks and regards
vikas singhalTry this:
DECLARE
TYPE t_sales IS RECORD(
id DBMS_SQL.NUMBER_TABLE,
p_o_no DBMS_SQL.VARCHAR2_TABLE,
party_name DBMS_SQL.VARCHAR2_TABLE,
prod_code DBMS_SQL.VARCHAR2_TABLE,
style_name DBMS_SQL.VARCHAR2_TABLE,
color DBMS_SQL.VARCHAR2_TABLE,
xs DBMS_SQL.NUMBER_TABLE,
s DBMS_SQL.NUMBER_TABLE,
m DBMS_SQL.NUMBER_TABLE,
l DBMS_SQL.NUMBER_TABLE,
xl DBMS_SQL.NUMBER_TABLE,
pcs DBMS_SQL.VARCHAR2_TABLE,
total_qty DBMS_SQL.NUMBER_TABLE,
comments DBMS_SQL.VARCHAR2_TABLE,
flag DBMS_SQL.NUMBER_TABLE);
a_sales t_sales;
TYPE t_sales_id_list IS TABLE OF SALE_ORDER%ROWTYPE
INDEX BY PLS_INTEGER;
a_sales_id_list t_sales_id_list;
v_curr_id NUMBER;
CURSOR c_sales IS
SELECT *
FROM (SELECT NULL id,
p_o_no,
party_name,
prod_code,
style_name,
color,
xs,
s,
m,
l,
xl,
pcs,
xs+s+m+l+xl total_qty,
comments,
ROW_NUMBER() OVER(PARTITION BY p_o_no,
party_name
ORDER BY p_o_no,
party_name) row_number
FROM po_pending_csv)
ORDER BY p_o_no,
party_name,
row_number;
v_timestamp DATE := SYSDATE;
v_array NUMBER := 1;
BEGIN
OPEN c_sales;
LOOP
FETCH c_sales BULK COLLECT
INTO a_sales LIMIT 100;
-- Logic to populate ID
FOR i IN 1 .. a_sales.id.COUNT
LOOP
IF a_sales.flag(i) = 1 THEN
-- Only get nexval for distinct values of p_o_no, party_name
SELECT sale_order_id_seq.NEXTVAL
INTO v_curr_id
FROM dual;
-- Assign new id to a_sales
a_sales.id(i) := v_curr_id;
-- Populate a_sales_id_list
a_sales_id_list(v_array).id := v_curr_id;
a_sales_id_list(v_array).sale_order_no := a_sales.p_o_no(i);
a_sales_id_list(v_array).order_date := v_timestamp;
a_sales_id_list(v_array).party_name := a_sales.party_name(i);
-- Increment counter
v_array := v_array+1;
ELSE
-- Populate a_sales id with last value
a_sales.id(i) := v_curr_id;
END IF;
END LOOP;
-- Insert into Sales Order
FORALL i IN 1 .. a_sales_id_list.COUNT
INSERT INTO SALE_ORDER
VALUES a_sales_id_list(i);
-- Insert into Sales Order Detail
FORALL i IN 1 .. a_sales.id.COUNT
INSERT INTO SALE_ORDER_DETAIL
(id,
prod_id,
style,
color,
xs,
s,
m,
l,
xl,
pcs,
total_qty,
comments)
VALUES
(a_sales.id(i),
a_sales.prod_code(i),
a_sales.style_name(i),
a_sales.color(i),
a_sales.xs(i),
a_sales.s(i),
a_sales.m(i),
a_sales.l(i),
a_sales.xl(i),
a_sales.pcs(i),
a_sales.total_qty(i),
a_sales.comments(i));
-- delete array
a_sales_id_list.delete;
-- reset counter
v_array := 1;
EXIT WHEN c_sales%NOTFOUND;
END LOOP;
CLOSE c_sales;
COMMIT;
END;Cheers -
Retriving data from two tables at a time.
Please use this forum to provide feedback about OTN content/services. All other posts will be DELETED.
hi all,
Am using win98 and Oracle 7.
I have splitted a table into two tables having 10 and 9 fields respectively and records of 2000.Now in form builder I have put both tables in same block and on same canvas.
Now when I execute a query I retrieve records of 1st table and can navigate through records of 1st table only .To retrive records of 2nd table I have to put curser in 2nd table and query again for data retrival from 2nd table.This is bothering me to match coulmn of both tables.
Is there any way to execute the records of both tables at a time, so that matching coulmns of both tables would become easy to reach.
Thanks and Regardsheeeey mohammad
you have first to make master/detail block not one block only
then jion between them as pk and fk -
Spliting a table in to two table based on the groups in SSRS
Hi,
I am trying to a split a rows accross two tables based on a group.
So far I have added a list and added a row group and grouped it using lineof business
Inside my list i have two identical tables so i can display the data
for the first table i have set the row visibility as follows: where LineOfbusiness1 is the groupname of my list group
=RowNumber(Nothing) >= (IIf(CountRows("LineOfBusiness1")\2 = 1, CountRows("LineOfBusiness1")/2, (CountRows("LineOfBusiness1")/2)+1))
and for the second table in the i have set the row visibility as follows
=RowNumber(Nothing)< (IIf(CountRows("LineOfBusiness1")\2 = 1,CountRows("LineOfBusiness1")/2, (CountRows("LineOfBusiness1")/2)+1))
this set up works fine for the first group but it doesnt display the data the way i want for the subsequent groups.
so how do i have the table start over after each group... plus in my group i have specified to do a page break after everygroup...
Any help will be appreciated.
Thanks
KarenVisakh,
Thanks for answering.... a sample for the data will look like
dataset----
create table #dataset
Code varchar(5),
Name varchar(200),
Lineofbusiness int,
Statename varchar(10),
typed int,
description varchar(2000)
insert into #dataset
select 45111,abc,1,AL,4500,policies
insert into #dataset
select 45111,abc,1,AL,2500,vehiles
insert into #dataset
select 45111,abc,1,AL,3,drivers
insert into #dataset
select 45000,bca,2,AL,4500,policies
insert into #dataset
select 45000,bca,2,AL,500,house
insert into #dataset
select 45000,bca,2,AL,40,theft
When i display the data i want it to be
Line of business 1
policies 4500 drviers 3
vehiles 2500
Line of business 2
Policies 4500 theft 40
House 500
but right now the for lineofbusiness 1 its showing the correct way for but the line 2 everything is being displayed in the right.
Thanks
Karen -
Two tables KUWEV and KUAGV joining
Hi all,
I have two tables KUWEV and KUAGV
The following field I have taken from two tables
KUWEV u2013VABED
KUWEV- LLAND
KUAGV-LAND1
If KUWEV u2013VABED =TRLOZ - VABED
and KUWEV- LLAND = TRLOZ - LLAND
and KUAGV-LAND1 = TRLOZ - LAND1
then only I have to pickup TRLOZ- ROUTE
after that i have to Substitute the value in VBAP-ROUTE
can anybody help to write the code
I have doubt that how can data we will pick up 2 fields from one table 1 field from another table and two tables (KUWEV and KUAGV) having common field KUNNR
Pointes will be rewarded by useful information
Thanks in advance
krishnaHi KCH,
either use joins or write separate select statements.
Hope it helps.
Aditya -
How to avoid Duplicate Records while joining two tables
Hi,
I am trying to join three tables, basically two tables are same one is like history table, so I wrote a query like
select
e.id,
e.seqNo,
e.name,
d.resDate,
d.details
from employees e,
((select * from dept)union(select * from dept_hist)) d
join on d.id=e.id and e.seqno=d.seqno
but this returing duplicate records.
Could anyone please tell me how to avoid duplicate records of this query.Actually it is like if the record is processed it will be moved to hist table, so both table will not have same records and I need the record from both the tables so i have done the union of both the tables, so d will have the union of both records.
But I am getting duplicate records if even I am distinct. -
ABAP table for "Condition table"
Dears,
Could you please tell the ABAP table for Condition table.
My requirement is : I need to check a field e.g. KUNNR, in which all the condition tables KUNNR is been used.
Thanks
pinkyHi,
Use t.code se16n, and then provide the sales order number for vbak,
or vbap take value of field KNUMV (The internal number under which
the system saves conditions that apply to a sales order header),
KNUMH (The internal number under which the system saves conditions
that apply to a sales orde itemr), and go to KONV (for vbak) and KONP
(for vbap) enter this KNUMV or KNUMH number and execute , you will get
all item pricing conditions for that sales order.
For pricing record :- table KONH - Condition (Header)
table KONP - Condition (Item)
with field KNUMH - Condition record number.
hope this will help.
regards
Vivek. -
Error when splitting a Table into two columns - Please help!
Hi!
I have created a table in which I have created a header which has been split into 3 parts conisting of 2 columns. These all work fine. However, when I try to split the row below the header row into 2 columns, it does so but, in a way, connects the line inbetween the two columns with the line inbetween the two columns above and will not allow me to move it left or right by manually changing specs or dragging the line. Please help! (I'm using CS5 by the way!) Thank you!I suggest you begin with a pre-built CSS Layout. DW has several to help jump start your projects. Go to File > New Blank Page > HTML. Select a layout from the 3rd panel and hit CREATE. See screenshot.
Save this layout as test.html and begin building your prototype page saving and validating code often during your work sessions.
Code Validation Tools
CSS - http://jigsaw.w3.org/css-validator/
HTML - http://validator.w3.org/
Good luck with your project!
Nancy O. -
Oracle rownum usage for splitting a Table into two equal parts.
Hi All,
I have a table which has like 1.2 billion records and i would have to split the table in two parts for my Archiving needs.Unfortunately that table does not have any unique key or primary key or data stamp which i can rely for.
I would have to use the rownum concept to divide the table.
I am using the below
SELECT * FROM (SELECT ENAME, SAL FROM EMP ORDER BY SAL DESC) WHERE ROWNUM < 5000000;
But the problem is that the table is taking forever to retrieve as it has to do a order by and then retrieve the data as per the where clause.
The question i have is that instead of using a orderby clause to get the same rownum for the row every time, can i directly rely on the fact that the database is read only and the Rownum would remain same even without oder by clause....
Thanks....WARNING! There is a bug in the code, see EDIT: at bottom of post for details
Justin,
It makes sense that Oracle could order over rowid without sorting, but I see a sort in the explain plan:
SQL> create table t as select 1 as data
2 from all_objects
3 where rownum <= 100000;
Table created.
SQL> explain plan for select *
2 from (select t.*, row_number() over (order by rowid) rn from t)
3 where rn < 50000;
Explained.
SQL> select * from table(DBMS_XPLAN.DISPLAY);
PLAN_TABLE_OUTPUT
Plan hash value: 327232321
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 99651 | 2530K| | 489 (3)| 00:00:07 |
|* 1 | VIEW | | 99651 | 2530K| | 489 (3)| 00:00:07 |
|* 2 | WINDOW SORT PUSHED RANK| | 99651 | 2432K| 7056K| 489 (3)| 00:00:07 |
| 3 | TABLE ACCESS FULL | T | 99651 | 2432K| | 31 (7)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("RN"<50000)
2 - filter(ROW_NUMBER() OVER ( ORDER BY ROWID)<50000)875820,
What are you doing with the results of the select to archive the table in two pieces? If the archive is in the DB in two seperate tables, multi table insert would be an option:
SQL> create table archive_1 (data number);
Table created.
SQL> create table archive_2 (data number);
Table created.
SQL> explain plan for insert when mod(rn, 2) = 0 then into archive_2 (data) values (data)
2 else into archive_1 (data) values(data)
3 select rownum as rn, data
4 from t;
Explained.
SQL> select * from table(DBMS_XPLAN.DISPLAY);
PLAN_TABLE_OUTPUT
Plan hash value: 828723766
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | INSERT STATEMENT | | 99651 | 2530K| 31 (7)| 00:00:01 |
| 1 | MULTI-TABLE INSERT | | | | | |
| 2 | INTO | ARCHIVE_2 | | | | |
| 3 | INTO | ARCHIVE_1 | | | | |
| 4 | VIEW | | 99651 | 2530K| 31 (7)| 00:00:01 |
| 5 | COUNT | | | | | |
| 6 | TABLE ACCESS FULL| T | 99651 | 1265K| 31 (7)| 00:00:01 |
SQL> insert when mod(rn, 2) = 0 then into archive_2 (data) values (data)
2 else into archive_1 (data) values(data)
3 select rownum as rn, data
4 from t;
100000 rows created.Another option would be to use the last digit of rowid to split the table into two groups, but they will not be equal sized.
SQL> explain plan for select *
2 from t
3 where substr(rowid, length(rowid), 1) = upper(substr(rowid, length(rowid), 1))
4 or substr(rowid, length(rowid), 1) in ('0', '1', '2', '3', '4');
Explained.
SQL> select * from table(DBMS_XPLAN.DISPLAY);
PLAN_TABLE_OUTPUT
Plan hash value: 2153619298
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 59025 | 1441K| 98 (71)| 00:00:02 |
|* 1 | TABLE ACCESS FULL| T | 59025 | 1441K| 98 (71)| 00:00:02 |
Predicate Information (identified by operation id):
1 - filter(SUBSTR(ROWIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)='0
' OR SUBSTR(ROWIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)='1' OR
SUBSTR(ROWIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)='2' OR
SUBSTR(ROWIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)='3' OR
SUBSTR(ROWIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)='4' OR
SUBSTR(ROWIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)=UPPER(SUBSTR(ROW
IDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)))
Note
- dynamic sampling used for this statement
23 rows selected.
SQL> explain plan for select *
2 from t
3 where substr(rowid, length(rowid), 1) <> upper(substr(rowid, length(rowid), 1))
4 and substr(rowid, length(rowid), 1) not in ('0', '1', '2', '3', '4');
Explained.
SQL> select * from table(DBMS_XPLAN.DISPLAY);
PLAN_TABLE_OUTPUT
Plan hash value: 2153619298
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 40627 | 991K| 41 (30)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| T | 40627 | 991K| 41 (30)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(SUBSTR(ROWIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)<>'
0' AND SUBSTR(ROWIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)<>'1' AND
SUBSTR(ROWIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)<>'2' AND
SUBSTR(ROWIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)<>'3' AND
SUBSTR(ROWIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)<>'4' AND
SUBSTR(ROWIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)<>UPPER(SUBSTR(RO
WIDTOCHAR(ROWID),LENGTH(ROWIDTOCHAR(ROWID)),1)))
Note
- dynamic sampling used for this statement
23 rows selected.
SQL> select count(*)
2 from t
3 where substr(rowid, length(rowid), 1) = upper(substr(rowid, length(rowid), 1))
4 or substr(rowid, length(rowid), 1) in ('0', '1', '2', '3', '4');
COUNT(*)
59242
SQL> select count(*)
2 from t
3 where substr(rowid, length(rowid), 1) <> upper(substr(rowid, length(rowid), 1))
4 and substr(rowid, length(rowid), 1) not in ('0', '1', '2', '3', '4');
COUNT(*)
40758
EDIT:
I realized that I screwed up above. In hind sight I don't know what I was thinking. I was attempting to use X = upper(X) to find the upper case characters A-Z. So the two queries to split rows based on the last character of rowid are not right. I don't have time to fix now, but wanted to leave a note of warning.
Edited by: Shannon Severance on Jul 29, 2011 1:34 AM -
Union two tables with diffrent count of fields with null and float value
Hello,
i want to union two tables, first one with 3 fields and second one with 4 fields (diffrent count of fields).
I can add null value at end of first select but it does not work with float values in second table. Value form second table is convert to integer.
For example:
select null v1 from sessions
union
select 0.05 v1 from sessions
result is set of null and 0 value.
As workaround i can type:
select null+0.0 v1 from sessions
union
select 0.05 v1 from sessions
or simple change select's order.
Is any better/proper way to do this? Can I somehow set float field type in first select?
Best regards,
Lukasz.
WIN XP, MAXDB 7.6.03Hi Lukasz,
in a UNION statement the first statement defines the structure (number, names and types of fields) of the resultset.
Therefore you have to define a FLOAT field in the first SELECT statement in order to avoid conversion to VARCHAR.
Be aware that NULL and 0.0 are not the same thus NULL+0.0 does not equal NULL.
In fact NULL cannot equal to any number or character value at all.
BTW: you may want to use UNION ALL to avoid the search and removal of duplicates - looks like your datasets won't contain duplicates anyhow...
Regards,
Lars -
Two tables with the same selectionModel
Hi to all..
I have been working on a project in java that needs to include two tables.Right now, I have successfully
built two tables (Table A and B) with different type of data from a database and each of it will update when user click a button.
The problem that i have is how to make sure that when user click a row in Table A, any selection in Table B will be deselect.
I am new in programming and still barely understand in Swing components.
Thanks.
Amywhere should I put the line of code.add a mouse listener in table A
put the code on mousePressed.
e.g.
tableA.addMouseListener(new java.awt.event.MouseListener() {
public void mouseClicked(MouseEvent e) {
public void mouseEntered(MouseEvent e) {
public void mouseExited(MouseEvent e) {
public void mousePressed(MouseEvent e) {
tableB.clearSelection();
public void mouseReleased(MouseEvent e) {
}); -
Left Outer Join with more than two tables in both CR 8.5 and XIR2
I am trying to create a report and I have tried two versions of Crystal but I ultimately need the report in CR8.5 for compatibility with the client's system. I think I am starting to figure out what might be wrong and it might be my understanding of SQL, but I can't see why someone hasn't needed this in the past. Ultimately I want to see all projects and any journal entry that might be posted for that project.
Database is MySQL 5.0.38 and using MySQL ODBC driver 3.51.19.
Project header table information will be populated. Each line item on a journal entry can be tagged with the project ID. But for me to pull the journal entry date I need also to link to a third table for the journal entry header info.
I want to see all projects, whether a journal entry has been posted or not.
So the links are like this
ProjectHeader --->Left Outer Join ---> JELines ---> Inner Join ---> JEHeader
I think in this scenerio Crystal is treating the LOJ as an IJ.
I created two brand new reports today, one in CR8.5 and one in CR XIR2. Once I edited the automatic CR8.5 SQL statement (which I have been doing for years, usually without problem), they both ran properly. I linked customers to their invoices. Customers without invoices showed properly. But then I linked the invoices to the payments of the invoices and immediately lost customers without orders in both reports.
So apparently only two tables are allowed in Outer Joins. Does this make sense? I checked out the w3schools tutorial on SQL and it doesn't mention this limitation and I can't find anywhere else that it specifically indicates this but all samples of code I have seen only show two tables. I just thought for presentation as a sample that was easiest to understand and we could expand as necessary.
If this is correct, how does one go about accounting for this kind of thing? One solution that goes through my mind is creating a view at the database level for the link between journal entry lines and journal entry headers. Would this be a good solution under normal circumstances?
A second option that I had to implement because of timelines, is to use a subreport linked to the main report through the project ID to pull the information for the journal entries and just pass the totals I need to the main report through a shared variable.
These aren't normal circumstances because I don't have access to the database so I can't create the view. I have come across this concept several times and I have been able to use subreports to solve it but I am trying to find a better solution for the future as sometimes subreports can be slow. So are there any alternatives I have not considered here?
TIA rasincSo after some more work and another post. I was able to get this to work.
Items disappear when linking to another table
My issues were two fold. I was selecting on the tables on the right-side of the original Inner Join. However, I was checking for Nulls. This apparently is correct but you must check for the Nulls first eg. (IsNull (JEHeader.Field1) OR JEHeader.Field1 <= 100). I had my original statement reversed checking for <= 100 before checking for Nulls.
I also did not set all links to be Left Outer Join. I had the Inner Join. I actually have about 6 tables in this report so all the links need to be set Outer Join. So this now seems to be corrected.
Thanks
Maybe you are looking for
-
ICloud Not Syncing After IOS 8 Upgrade
Is anyone else having trouble where nothing updates within iCloud. I make a calendar alteration or edit a numbers or pages file and it never uploads to iCloud. Or if you edit something on the iCloud website it never syncs down to my IOS devices.
-
I tried to set up my wi fi but i typed in the wrong password, how can i change it?
My ipad prompted me to enter the password for my wifi network but of course i typed in the wrong one... now it is not giving me an option to retype it in for this wifi network it just opens pop up screen that says "unable to connect" my other ipad
-
Need Help with Memory OC to 1066 on P35 Platinum Combo
Hi, I've been trying to get my Corsair Dominator memory to 1066, but everytime I change settings, the system will not post. So far I've: - Disabled EIST & DOT - Disabled 'Configure DRAM Timing by SPD' and set values to 5-5-5-15 (left all others as is
-
Quicktime 7 wont play h.264 video??? how can i change that?
Hey there I just tried to open a avi file in imovie and noticed that i could not import it. so i opened it with quicktime, but all it does is pop up a screen telling me, that a certain codec is missing. I would get that codec if i only knew which one
-
Getting music from Real One player
Does anyone know how to get music from real one player into the ipod? I am an idiot when it comes to techy stuff, so now i've got a new nano, but I don't know how to extract music from realone player. I tried add file to library option, but that didn