How to join each row with other in the same table without repeating, please help
Hi,
I have a table say Adjustment having following data
Emp_Id
Adjustment_id
Date
1000101
1000300
2014-02-12 00:00:00.000
1000101
1000301
2014-02-12 00:00:00.000
1000101
1000302
2014-02-12 00:00:00.000
1000101
1000303
2014-02-12 00:00:00.000
1000102
1000302
2014-02-12 00:00:00.000
1000102
1000303
2014-02-12 00:00:00.000
1000102
1000304
2014-02-12 00:00:00.000
And I want following records:
Emp_Id
Adjustment_id Adjustment_id1
Date
1000101
1000300 1000301
2014-02-12 00:00:00.000
1000101
1000300 1000302
2014-02-12 00:00:00.000
1000101
1000300
1000303
2014-02-12 00:00:00.000
1000101
1000301 1000302
2014-02-12 00:00:00.000
1000101
1000301 1000303
2014-02-12 00:00:00.000
1000101
1000302 1000303
2014-02-12 00:00:00.000
1000102
1000302 1000303
2014-02-12 00:00:00.000
1000102
1000302 1000304
2014-02-12 00:00:00.000
1000102
1000303
1000304
2014-02-12 00:00:00.000
Hi Uri,
I am using SQL Server 2008, and I am trying join each adjustment_id with all other adjustment_id having same Date and Emp_id.
so for following table records:
Emp_Id
Adjustment_id
Date
1000102
1000302
2014-02-12 00:00:00
1000102
1000303
2014-02-12 00:00:00
1000102
1000304
2014-02-12 00:00:00
Output should be:
Emp_Id
Adjustment_id Adjustment_id
Date
1000102
1000302 1000303
2014-02-12 00:00:00 (first row with 2nd)
1000102
1000302 1000304
2014-02-12 00:00:00 (first row with 3rd)
1000102
1000303 1000304
2014-02-12 00:00:00 (2nd row with 3rd)
Similar Messages
-
Update multiple rows with datas from the same table
i have a table like
name version value1 value2
2 A 4,31 3,5
3 A 3,45 10
2 B 6,97 12
4 B 12 16
so name + version is unique
i have to update the datas value1 and value2 ( version A) with the datas from version B where the name ( VersionA) = name version B
i.e the result should be
name version value1 value2
2 A 6,97 12
3 A 3,45 10
2 B 6,97 12
4 B 12 16
is it possible to do this in sql? ( sql. 8.1)... if your table does not contain exactly what you expect you could get:
'single row sub-query returns more than one row'
To prevent that, put a unique index on (name, version). If this combination is not always unique, you will need to cater for the possibility in the update statement. -
My iPad and iPhone have the same syncing calendar but my Windows 7 PC with iCloud does not sync/show the same calendar...please help!
iCloud will not sycn a calendar from an external source. In order to use iCloud to sync it, you would have to move it to iCloud and stop using Google. I know how to do that on a Mac, but I'm not sure how to do it on a PC. If you're using Outlook, I suspect you export it as an .ics file to your desktop, then import it to the iCloud account in Outlook. I'm sure you could use Google to find the specific steps.
However, there's really no reason not to just use Google to sync your calendar across your devices. Instead, just continue to use Goole calendar on all your devices and they should stay in sync. Take a look at this video: http://www.youtube.com/watch?v=C0Jj0KFgbYI. -
when i turn on itunes, it crashes automatically with the error message saying "itunes has encountered a problem and needs to close." I've tried reinstalling itunes but its the same. CAN SOMEONE PLEASE HELP!!!
Try:
iOS: If you can't back up or restore from a backup in iTunes -
How do i share pictures with other users on my Mac without using iCloud or photo stream
How do I share pictures woth other users on my Mac without using iCloud or photo streaming?
Simplest way is probably to put copies into the Users/Shared folder.
-
How can I start a new paragraph within the same table cell?
In Numbers, when adding text within a table frame, how can I start a new line within the same frame (rather than advancing to the next cell)? I'd like to enter a mini-list of several items of various lengths of data.
While Wayne's answer solves your problem, another possibility is to uncheck the box at the bottom of the Table inspector for "Return key moves to next cell." If that is unchecked, the return key types a paragraph return within the cell (the same as Option Return with the box checked).
With that box unchecked, Shift Return types a soft return (new line without a paragraph break). -
How to copy existing row value into new row with a trigger. Same table
Oracle guru,
I am looking for a before or after trigger statement that will copy existing values inserted in the previous row into columns A & B. Then insert those values in a new row into column A & B if null? Same table. Hopefully my question is clear enough.
-Oracle 10g express
-I have an existing " before insert trigger" that insert id and timestamps when a new row is created.
-Table is composed of column like id,timestamps,A,B and more.
Thanks in advance
Pierre957911 wrote:
Oracle guru,
I am looking for a before or after trigger statement that will copy existing values inserted in the previous row into columns A & B. Then insert those values in a new row into column A & B if null? Same table. Hopefully my question is clear enough.
-Oracle 10g express
-I have an existing " before insert trigger" that insert id and timestamps when a new row is created.
-Table is composed of column like id,timestamps,A,B and more.
Thanks in advance
PierreI will call it a very Wrong design.
It is a wrong Table Design. You are duplicating the data in table and not complying with the Database Normalization rules.
How about Verifying if Column A & B are NULL before inserting and inserting another row and avoiding it in Triggers?
If you are bent to achieve this, below code might be helpful. However, I would never go with this approach. If you would care about explaining the reason for going ahead with such a data model, people could suggest better alternative that might conform with Normalization rules.
create or replace trigger trg_test_table
after insert on test_table
for each row
declare
pragma autonomous_transaction;
begin
if :new.col_a is null and :new.col_b is null then
insert into test_table
select 2, systimestamp, col_a, col_b
from test_table
where pk_col = (select max(pk_col) from test_table b where b.pk_col < :new.pk_col);
end if;
commit;
end trg_test_table;Read SQL and PL/SQL FAQ and post the mentioned details.
Do not forget to mention output from
select * from v$version; -
The type I am referring to is the words "What to do next" above.
On the left is what they look like in the native InDesign CS5 file they were created in. This is how I would like them to appear.
On the right is how they appear when I try to save the brochue as a .pdf.
My question is how can I get the words "What to do Next" to appear the same in the .pdf as they do in the native InDesign file?
Thanks for your help!
SM66Effects are usually using some type of blending mode - you should preview your InDesign file using View>Overprint Preview
That will show you what they look like when they blend with the background. -
How can I export schema with all objects and few tables without data
Hi all
Verion 10g EE.
I have to export schema with all objects but i need to ingnore some of the table data.
There are 4 table those have huge data, we need not to export those tables data but structure should export.
Thanks,
NrYou can do this with a single command. Run your export as normal and add query parameters for the 4 tables that you don't want any rows:
expdp ... query=schema1.table1:"where rownum = 0" query=schema2.table2:"where rownum = 0" ...
It is best to put the query parameters in a parameter file so you don't have to worry about escaping any OS special characters.
Dean -
How to update colomn depend on the other in the same table
hi ,
i have the following table with 2 colomns (A and B)
A B
100 null
90 null
80 null
70 null
60 null
and i want move the first max 2 number to the colomn B to be like this
A B
80 100
70 90
60 null
and help please ,with t as ( select 100 A, null B from dual union
select 90, null from dual union
select 80 ,null from dual union
select 70, null from dual union
select 60, null from dual)
select A, B
from t
model
dimension by (row_number() over (order by A desc) num )
measures (A, cast (null as number) B, count(*) over () cnt )
RULES (
B [for num from 1 to 2 increment 1] = A[cv()],
A[for num from 1 to cnt[1] increment 1] = A[cv() + 2]
A B
80 100
70 90
60Edited by: pollywog on Jun 15, 2011 3:44 PM
or if you have 11g there is now a fuction called nth_value
/* Formatted on 6/15/2011 4:03:51 PM (QP5 v5.149.1003.31008) */
WITH t AS (SELECT 100 A, NULL B FROM DUAL
UNION
SELECT 90, NULL FROM DUAL
UNION
SELECT 80, NULL FROM DUAL
UNION
SELECT 70, NULL FROM DUAL
UNION
SELECT 60, NULL FROM DUAL)
SELECT LEAD (A, 2) OVER (ORDER BY A DESC) A,
CASE
WHEN A < NTH_VALUE (MAX (A), 2) OVER (ORDER BY A DESC) THEN NULL
ELSE A
END
B
FROM t
GROUP BY AEdited by: pollywog on Jun 15, 2011 4:04 PM -
How I program a project as others program the same proyect
I have 3 person In the same project (in diferent PC), well I need to program the 3 person In the same time (for example via Internet), for example I work in a class and when save the 3 person can view the save, there a program to make this
peterdavis wrote:
I have 3 person In the same project (in diferent PC), well I need to program the 3 person In the same time (for example via Internet), for example I work in a class and when save the 3 person can view the save, there a program to make thisI'd suggest you look at a version control system like CVS or Subversion (SVN).
Winston -
Measure using UseRelationship not working well when sliced with attributes from the same table
Hi,
I have Measure created using the 'UseRelationship' Function, which uses a different datekey to link to the DateDim than the one the table is directly related by. The measure works as expected except in one scenario.
If I browse the measure using an attribute from the same fact table then the attribute is filtered using active relationship whereas the measure is filtered using the inactive relationship as shown below:
FACT(2 rows)(Active Relationship to Date using DateKey1)
SNo DateKey1 DateKey2 Geo Amt
1 20100101 20120101 India 100
2 20100101 20120101 US 200
AmtMeasure:=CALCULATE(SUM([Amt]),USERELATIONSHIP(FACT[DateKey2],'Date'[DateKey]))
If I browse the above measure in excel, with Year selected as 2012, I get 100+200=300. Now if I drag the Geo attribute against the measure I get 2 rows with 100 and 200.
If I do the same in a power view report I don't get any results after dragging the Geo attribute, whereas I get the correct value of 300 without the geo attribute. I checked the DAX query which the power view generates and figured this is being caused because
there are no rows in the table with DateKey1 having year 2012. I understand why this is happening this way in a DAX query and not in MDX, but shouldn't both behave in the same way and what is a work around.
Thanks,
Sachin ThomasSac, is this still an issue?
Thank you!
Ed Price, Azure & Power BI Customer Program Manager (Blog,
Small Basic,
Wiki Ninjas,
Wiki)
Answer an interesting question?
Create a wiki article about it! -
How can I share iphotos with others on the web using photo stream?
The apple instructions for iPhoto 11 says:
It’s easy to create a photo stream to share your photos. You can also view the photos you’ve already shared.
To create a shared photo stream:
Select the photos you want to share.
In the toolbar, click the Share button, choose Photo Stream from the pop-up menu, and then click New Photo Stream.The New Shared Photo Stream dialog appears.
In the To field, type the email addresses for your invitees.To enable your invitees to access the shared photo stream from an iOS device, you must provide the email addresses associated with their iCloud accounts.
In the Name field, type a name for the photo stream.
etc
All I get is that photo is already shared, or no dialogues at all
I certainly never get a chance to choose a "New Photo Stream" oenter an email address
WHAT AM I DOING WRONG?What version of iPhoto?
Directions for setting up diferent devices including minimum software versions required fore different features like Shared PhotoStreams are heree - http://www.apple.com/icloud/setup/
LN -
HT3819 how can i share itunes with users on the same computer?
My husband and I both have separate user profiles on our Mac. Is there a way we can access all the music files from our itunes between the two profiles?
I puzzled this out a while back. Lets see if i can at least point you in the right direction.
From the Admin account open System Prefrences>Sharing
on the left there is a check box for "file Sharing" check this box.
to the right you can add folders, add "iTunes Media"
then you can add Users. add the users that can share that folder.
then open the other account that wants to share that folder.
open their iTunes>Prefrences>Advanced. Uncheck the box that says "Copy files to iTunes Media folder when adding to library"
then open Finder and the shared iTunes Media folder should be on the left... (fingers crossed)
the only problem is that any time you add media to the admin account, you have to go into the other account and add it to that itunes.
hassle, but it's what i do.
Good Luck -
Different number of rows when add/delete the same table
Hi,
i've a problem in a select statement.
My database is a 9.2.0.8.
select *
from tab1 t1,
tab2 t2,
tab2 t3
where t1.id_c1 = 1
AND t1.id_c2 = t2.id_c2
AND t1.id_c2 = t3.id_c2
AND t2.id_init = 3693
AND t3.id_init = 3892;
936 rows selected.if i change the query in:
select *
from tab1 t1,
tab2 t2
where t1.id_c1=1
AND t1.id_c2 = t2.id_c2
AND t2.id_init in ( 3693,3892);
61132 rows selected.Any ideas? what's wrong??
Tnx
Edited by: 842366 on 10-ago-2011 3.10
Edited by: 842366 on 10-ago-2011 3.10You can see the difference yourself with this sample test data.
SQL> with t_data1 as
select 1 as id_c1,2 as id_c2 from dual union all
select 2 ,2 from dual
t_data2 as
select 1 as id_c2, 3693 as id_init from dual union all
select 1, 3693 from dual union all
select 1, 3892t from dual union all
select 1, 3892 from dual union all
select 2, 3693 from dual union all
select 2, 3892 from dual union all
select 2, 3892 from dual
select *
from t_data1 t1,
t_data2 t2
where t1.id_c1=1
AND t1.id_c2 = t2.id_c2
AND t2.id_init in ( 3693,3892);
ID_C1 ID_C2 ID_C2 ID_INIT
1 2 2 3693
1 2 2 3892
1 2 2 3892
SQL> SQL>
SQL>
SQL>
SQL> with t_data1 as
select 1 as id_c1,2 as id_c2 from dual union all
select 2 ,2 from dual
t_data2 as
select 1 as id_c2, 3693 as id_init from dual union all
select 1, 3693 from dual union all
select 1, 3892t from dual union all
select 1, 3892 from dual union all
select 2, 3693 from dual union all
select 2, 3892 from dual union all
select 2, 3892 from dual
select *
from t_data1 t1,
t_data2 t2,
t_data2 t3
where t1.id_c1 = 1
AND t1.id_c2 = t2.id_c2
AND t1.id_c2 = t3.id_c2
AND t2.id_init = 3693
AND t3.id_init = 3892;
ID_C1 ID_C2 ID_C2 ID_INIT ID_C2 ID_INIT
1 2 2 3693 2 3892
1 2 2 3693 2 3892
SQL> We see that in both the queries, the no. of column returned are different. In first it is 4 and in 2nd it returns 6.
Now ask yourself, what is the use of this query, and how I am suppose to use the values returned and also what is the purpose for each value.
Once you have the answers for these questions, the requirement becomes more clearer, doubts vanish and more often you can do things yourself.
Maybe you are looking for
-
Photoshop mac CS5 constantly quits unexpectedly on open. Possibly from a system update?
Hey guys, I can't open photoshop after running an update on my OS. I'm not sure if it's related, as photoshop started crashing several hours later, I can't remember whether I had it working in the meantime - but I don't think I used it. It first happ
-
IMac G5 wont recognize previously recognized display. Need Help.
I've had an LCD display connected from DVI to HDMI and has worked fine as an extended desktop for months. Now after a restart, it won't recognize the display. It is connected the same way it was before, I've tried reconnecting, restarting still wont
-
How do I get my scheduled recordings from the old DVD to the new DVD?
My DVD died. I installed the new one and it works, but the scheduled recordings aren't there. How do I retrieve them from the old box?
-
I need a cf script that finds out the total row count of a sql database...Any idea? The reason I need is to compare our current db (on SQL05) with the new one that will be attached to the SQL 05....
-
What are the advantages/disadvantages between using iDVD or Toast 8 for burning iMovie video projects to DVD?