two rows of back with a single column with just one place
Hello all;I have a query that returns two rows similar to this below
ID PLACE PROGRAM
A NEWYORK PROGRAM A
A NEWYORK PROGRAM B
I would like this instead
ID PLACE PROGRAM
A NEWYORK PROGRAM A
PROGRAM B
All help is appreciated. Thank you.
Published by: user13328581 on March 22, 2011 11:52
user13328581 wrote:
WOW... Thanks a lot for Salomon, I never used the partitions and row_number in such a way... can you please explain your logic.
Ensure that:
ROW_NUMBER() over (partition by order of identification by location, program)
This operation can take all the rows returned by the query andsplit them in compartments (sheet music) by id. Inside each bucket it order lines by program and place and assign line numbers. So for each row of the ID number 1 will be stored with (in alphabetical order) first place the first programt. And this is the line where we want to ID is displayed. That's why we wrap the analytical function that precedes in the CASE statement that will do just that. Now:
ROW_NUMBER() over (partition by id, order by program)
pretty much the same just bucket is a combination ID / PLACE. So for each combination of it, we want to show that for the first (in alphabetical order) programt.
Now notice in the ORDER BY clause I prefix ID and PLACE with the table alias. You do it because otherwise the query alias ID and PLACE will have priority resulting in the incorrect sort order (remember that we cancelled all ID and PLACE with the exception of the number of line 1).
SY.
Tags: Database
Similar Questions
-
two rows of delete with different values
Hello
I wouldn't lines with the same id and have values of E and F 10258932.
I would like the following data:
But I have the following lines:A B C D E N -------- -- ------ ----- - - 10258927 1 103,35 0 10258929 3 284,85 89,52 E N 10258929 4 323,85 89,52 E N 10258930 5 478,80 91,53 E N 10258931 6 436,67 78,09 E N
Does anyone have an idea?SQL> with my_table as 2 ( 3 select '10258927' a, '1' b, '103,35' c, '0' d, NULL e from dual union all 4 select '10258928' a, '2' b, '0' c, '15,19' d, 'E' e from dual union all 5 select '10258929' a, '3' b, '284,85' c, '89,52' d, 'E' e from dual union all 6 select '10258929' a, '4' b, '323,85' c, '89,52' d, 'E' e from dual union all 7 select '10258930' a, '5' b, '478,80' c, '91,53' d, 'E' e from dual union all 8 select '10258931' a, '6' b, '436,67' c, '78,09' d, 'E' e from dual union all 9 select '10258932' a, '7' b, '784,88' c, '23,19' d, 'E' e from dual union all 10 select '10258932' a, '8' b, '100,88' c, '11,11' d, 'E' e from dual union all 11 select '10258932' a, '9' b, '300,88' c, '22,22' d, 'F' e from dual union all 12 select '10258932' a, '10' b, '468,25' c, '78,33' d, 'F' e from dual) 13 select a, b, c, d, e, no_ds from 14 ( 15 select a, b, c, d, e, 16 case when c > 0 and e != 'F' 17 then 'N' 18 end no_ds 19 from my_table) 20 where no_ds = 'N' or e is null 21 order by 1 22 / A B C D E N -------- -- ------ ----- - - 10258927 1 103,35 0 10258929 3 284,85 89,52 E N 10258929 4 323,85 89,52 E N 10258930 5 478,80 91,53 E N 10258931 6 436,67 78,09 E N 10258932 7 784,88 23,19 E N 10258932 8 100,88 11,11 E N 7 Zeilen ausgewählt. SQL>
Oh, I read the title again once: 'remove double lines with different values.
If it means that he is not specifically E and F values, but only if there is more than one distinct value, then you can do the following:with my_table as ( select '10258927' a, '1' b, '103,35' c, '0' d, NULL e from dual union all select '10258928' a, '2' b, '0' c, '15,19' d, 'E' e from dual union all select '10258929' a, '3' b, '284,85' c, '89,52' d, 'E' e from dual union all select '10258929' a, '4' b, '323,85' c, '89,52' d, 'E' e from dual union all select '10258930' a, '5' b, '478,80' c, '91,53' d, 'E' e from dual union all select '10258931' a, '6' b, '436,67' c, '78,09' d, 'E' e from dual union all select '10258932' a, '7' b, '784,88' c, '23,19' d, 'E' e from dual union all select '10258932' a, '8' b, '100,88' c, '11,11' d, 'E' e from dual union all select '10258932' a, '9' b, '300,88' c, '22,22' d, 'F' e from dual union all select '10258932' a, '10' b, '468,25' c, '78,33' d, 'F' e from dual ) -- -- end-of-test-data -- select a, b, c, d, e, num_distinct_values from ( select a, b, c, d, e, count(distinct e) over (partition by a) num_distinct_values from my_table) where num_distinct_values <= 1 order by 1 /
The county notes how the distinct non-null values in column e for each one.
Where clause then selects those with count = 0 (this is where e = null) and count = 1.
If the number is greater than 1, different values exist for this id.Choose what fits your condition ;-)
-
Disable the single column of Table
Hi all
It's perhaps something very stupid to ask.
Would have a Table control in which two first column will not be editable by the user and remaining user.
How can I go about disabling the two columns of the table control?
Thanks in advance.
The attached code turns off the first two rows, but to change it to columns simply change the value to unbundle to column.
-
When I open Firefox there is a black bar, sometimes vertical, sometimes horizontal, in the upper part, with links to maps, Gmail etc. When I opened Gmail the same links are listed at the top of the screen, just under the tabs. In my wife's cell phone, it appears in the Firefox splash screen, but not in the form of Gmail. In the top of the screen is an extra-large gray bar with just one Google search box entry. Is this a problem of Firefox or Google?
She has XP Home SP3 and Firefox 9
Thanks for any help.
Is there still the Google URL in the address bar?
Reload Web pages, and ignore the cache.
- Hold SHIFT and click reload.
- Press 'Ctrl + F5' or 'Ctrl + Shift + R' (Windows, Linux)
- Press 'Cmd + Shift + R' (MAC)
-
In the past, I used to reload a page several times with just one press the F5 key, with pressing long it charge more often, now long or short by pressing the F5 key is sufficient to reload a page or two times
OK guys, I found the problem, it was because I had MCAFEE Advisor which limited my refreshes, but when I disabled it, everything is back to normal, loool
-
Single line based on two columns and a single column
Dear members,
I have a table that contains duplicate rows, for which a request should be able to extract the unique row in the table. Here the unique is not based on a single column, but it should be in two columns and also check on the uniqueness on a column.
create table addr (varchar2 (10) firstname, lastname varchar2 (10), area varchar2 (3));
insert into values addr ('bob', 'james', 1');
insert into values addr ('bob', 'james', 1');
insert into values addr ('harry', 'bert', ' 1');
insert into values addr ('jimmy', 'bert', ' 1');
insert into values addr ('sam', 'mac', '1');
insert into values addr ('sam', 'Knight', '1');
insert into values addr ('tom', 'sand', '1');
insert into values addr ("cat", "mud", "1");
The query output must contain 3 lines.
Bob - james
Harry - bert or jimmy - bert [or the other of them], but not both
-Mac or sam - Sam Knight [or the other of them], but not both
Tom - sand
Cat - mud
SELECT firstname, lastname as total area WHERE addr = '1' GROUP by firstname, lastname; It takes no duplication of single column...
Any suggestions...SQL> with t_data as ( select 'bob' as firstname, 'james' as lastname, '1' as area from dual union all select 'bob', 'james', '1' from dual union all select 'harry', 'bert', '1' from dual union all select 'jimmy', 'bert', '1' from dual union all select 'sam', 'mac', '1' from dual union all select 'sam', 'knight', '1' from dual union all select 'tom', 'sand', '1' from dual union all select 'cat', 'mud', '1' from dual ) SELECT firstname, lastname, area FROM ( SELECT t.*, row_number() over(partition BY firstname order by 1) rn, row_number() over(partition BY lastname order by 1) rn1 FROM t_data t ) WHERE rn = 1 AND rn1 =1 ; FIRSTNAME LASTNAME AREA --------------- --------------- ---------- bob james 1 cat mud 1 jimmy bert 1 sam knight 1 tom sand 1 SQL>
-
Two foreign keys of a table in a single column
Hi gurus
I wonder that can we add two foreign keys of a table on a single column, I think the answer is, but what should be the reason behind this?
Appreciate if someone there explain to me...
Concerning
Muzz
Hello Muzz,
Perhaps the example of human Chen reveals a design error.
If a student has a 'teacher_id' "teacher" FK and FK for "emp" becaue each teacher is an EMP, I guess that the correct design would be to have only the FK of 'teacher' and to have another pointing to the 'emp' table in the 'teacher' tabe FKBut we can imagine comical situations...
CREATE TABLE PEOPLE (id NUMBER of KEY PRIMARY, name VARCHAR2 (20 CHAR),...);
CREATE TABLE SCIENTIST (id people KEY PRIMARY NUMBER (id) REFERENCES, discipline VARCHAR2 (20 CHAR),...);
CREATE TABLE POLICEMAN (id REFERENCES to KEY PRIMARY NUMBER (id), hire_date people DATE,...);First table = all.
2nd: a subset of the first, with people having the profile of 'scientific '...
3rd: a subset of the first, with people being a policeman.
It might be people first table and in none of the 2nd and 3rd, 1st and 2nd, 1st and 3rd only or in the 3 tables.Then we can have a fourth table of 'something' referring to a person who must be a scientist and a police officer.
Here is a sqlplus session illustrating; the last piece: I try inserting several lines in xxxx, only the last is accepted.
SQL > CREATE TABLE PEOPLE (id NUMBER of the PRIMARY KEY, name VARCHAR2 (20 CHAR));
Table created.SQL > CREATE TABLE SCIENTIST (people of REFERENCES of KEY PRIMARY NUMBER id (id), discipline VARCHAR2 (20 CHAR));
Table created.SQL > CREATE TABLE POLICEMAN (people of REFERENCES of KEY PRIMARY NUMBER id (id), DATE hire_date);
Table created.SQL > CREATE TABLE XXXX (id PRIMARY KEY NUMBER, people_id NUMBER, any other VARCHAR2 (30 CHAR));
Table created.SQL > ALTER TABLE ADD CONSTRAiNT fk_xxsci FOREIGN KEY (people_id) scientific xxxx REFERENCES (id);
Modified table.SQL > ALTER TABLE ADD CONSTRAiNT fk_xxpol FOREIGN KEY (people_id) police xxxx REFERENCES (id);
Modified table.SQL > INSERT INTO person VALUES (100, 'John');
1 line of creation.SQL > INSERT INTO person VALUES (120, 'Mary');
1 line of creation.SQL > INSERT INTO person VALUES (103, 'Tom');
1 line of creation.SQL > INSERT INTO person VALUES (123, "Bruno");
1 line of creation.SQL > INSERT INTO VALUES of scientific (120, 'Chemistry');
1 line of creation.SQL > INSERT INTO scientific VALUES (123, 'Mathematics');
1 line of creation.SQL > INSERT INTO VALUES of policeman (103, DATE ' 2001-04-01');
1 line of creation.SQL > INSERT INTO VALUES of policeman (123, DATE ' 1998-07-01');
1 line of creation.SQL > INSERT INTO xxxx VALUES (1, 456, "nothing");
ERROR on line 1:
ORA-02291: integrity constraint (SYS. FK_XXPOL) violated - key parent not foundSQL > INSERT INTO xxxx VALUES (1, 100, "only to people");
ORA-02291: integrity constraint (SYS. FK_XXPOL) violated - key parent not foundSQL > INSERT INTO xxxx VALUES (1, 120, "only the learned");
ORA-02291: integrity constraint (SYS. FK_XXPOL) violated - key parent not foundSQL > INSERT INTO xxxx VALUES (1, 103, "only police officer");
ORA-02291: integrity constraint (SYS. FK_XXSCI) violated - key parent not foundSQL > INSERT INTO xxxx VALUES (1, 123, 'ok');
1 line of creation.Best regards
Bruno Vroman.
-
PivotTable with header in two rows
Hello
is it possible to split a large pivot table to the narrower PivotTable with two heads?
I need to achieve this result: [http://img30.imageshack.us/img30/2339/oraclebipivotmultiplehe.jpg]
Column with total didn't need to be formatted as it is on the screenshot. But for me it is important to split a long pivot table two rows header...
Thank youI have the solution. I have transformed an original table with clean function js and jQuery
function transformPivotTable (tableId) {}
var $tables = $("#" + tableId + "table.) Pivot table");
If ($tables.length == 1 & $tables.attr("id").substr (0.3) == 'vu') {}
var $table = $tables;
var $headings1 = $table.find ("tr:eq (0) td:lt (11)");
var $headings2 = $table.find ("tr:eq (0) td:gt (10)");
var $values1 = $table.find ("tr:eq (1) td:lt (11)");
var $values2 = $table.find ("tr:eq (1) td:gt (10)");
$table.find ("tr:eq (0)") .html ($headings1);
$table.find ("tr:eq (1)") .html ($values1);
var $newrowHeadings = $(')") .addClass ("PTRowLabelsRow");
var $newrowValues = $(')");
$newrowHeadings.html ($headings2);
$newrowValues.html ($values2);
$table.append ($newrowHeadings);
$table.append ($newrowValues);
}
}This function can be performed by button or after the page loads:
transformPivotTable('d\\:dashboard\\~p\\:0fbi1pfhhtepur3d\\~s\\:vpjrrqes9j4sbo2kContents');
' d\\:dashboard\\ ~ p\\:0fbi1pfhhtepur3d\\ ~ s\\:vpjrrqes9j4sbo2kContents' is ID to lock up the HTML table with escape characters. It was the final table with ID fixed. Other nested tables had dynamic IDs, so I had to go with fixed ID and my PivotTable to search for the attribute class.
-
Trying to create a Section to multiple columns with Sections of the single column before and after
Is there a way to create a section break that is not default to a new page after I created columns on a page. I created the columns and under them, I want to return to the normal formatting for the rest of the single page. See picture attached.
Any rejection of Pages v5 has a break of presentation which was present in the Pages ' 09 v4.3. This will allow you to transition to several columns and back to single column on the same page. In the v5 Pages, you can insert 3 text boxes and change the 3-column layout in the Middle text box. You use the toolbar item Insert to inject column breaks when you want to start a new list in the next column. I'll show this screenshot below.
You can fake your layout in Pages v5 using 3 text boxes and setting 3 columns in the Central text area. Better to show the mode of provision for this and in a text box, the column outlines are not displayed. After each column list, you then choose column break the Insert point toolbar menu to move to the next column, add a list, repeat. Each column will expand downwards. Click on the following to enlarge.
Pages ' 09 v4.3 using layout breaks Pages using 3 text boxes V5.6.1
-
Mr President.
My worm jdev is 12.2.1
How to enter two rows at the same time with different default values that only the first line to use see?
Suppose I have a table with four fields as below
"DEBIT" VARCHAR2(7) , "DRNAME" VARCHAR2(50), "CREDIT" VARCHAR2(7) , "CRNAME" VARCHAR2(50),
Now I want that when I click on a button (create an insert) to create the first line with the default values below
So if I click on the button and then validate the second row with different values is also inserted on commit.
The value of the second row are like the picture below
But the second row should be invisible. It could be achieved by adding vc in the vo.
The difficult part in my question is therefore, to add the second row with the new default values.
Because I already added default values in the first row.
Now how to add second time default values.
Concerning
Mr President
I change the code given by expensive Sameh Nassar and get my results.
Thanks once again dear Sameh Nassar .
My code to get my goal is
First line of code is
protected void doDML(int operation, TransactionEvent e) { if(operation != DML_DELETE) { setAmount(getPurqty().multiply(getUnitpurprice())); } if (operation == DML_INSERT ) { System.out.println("I am in Insert with vid= " + getVid()); insertSecondRowInDatabase(getVid(),getLineitem(),"6010010","SALES TAX PAYABLE", (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100)); } if(operation == DML_UPDATE) { System.out.println("I am in Update with vid= " + getVid()); updateSecondRowInDatabase(getVid(), (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100)); } super.doDML(operation, e); } private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4, Object value5) { PreparedStatement stat = null; try { String sql = "Insert into vdet (VID,LINEITEM,DEBIT,DRNAME,AMOUNT) values " + "('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "','" + value5 + "')"; stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } } private void updateSecondRowInDatabase(Object value1, Object value5) { PreparedStatement stat = null; try { String sql = "update vdet set AMOUNT='"+ value5+"' where VID='" + value1 + "'"; stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } }
Second line code is inside a bean method
public void addNewPurchaseVoucher(ActionEvent actionEvent) { // Add event code here... BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry(); DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator"); RowSetIterator rsi = dciter.getRowSetIterator(); Row lastRow = rsi.last(); int lastRowIndex = rsi.getRangeIndexOf(lastRow); Row newRow = rsi.createRow(); newRow.setNewRowState(Row.STATUS_NEW); rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow); rsi.setCurrentRow(newRow); BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry(); DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator"); RowSetIterator rsi1 = dciter1.getRowSetIterator(); Row lastRow1 = rsi1.last(); int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1); Row newRow1 = rsi1.createRow(); newRow1.setNewRowState(Row.STATUS_NEW); rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1); rsi1.setCurrentRow(newRow1); }
And final saveUpdate method is
public void saveUpdateButton(ActionEvent actionEvent) { // Add event code here... BindingContainer bindingsBC = BindingContext.getCurrent().getCurrentBindingsEntry(); OperationBinding commit = bindingsBC.getOperationBinding("Commit"); commit.execute(); OperationBinding operationBinding = BindingContext.getCurrent().getCurrentBindingsEntry().getOperationBinding("Commit"); operationBinding.execute(); DCIteratorBinding iter = (DCIteratorBinding) BindingContext.getCurrent().getCurrentBindingsEntry().get("VdetView1Iterator");// write iterator name from pageDef. iter.getViewObject().executeQuery(); }
Thanks for all the cooperation to obtain the desired results.
Concerning
-
Single-column-multi-Rows, columns by using Types of Collection
Can you guys help me get the result after using types of collection or all the predefined collections?
In fact, I'm trying to compare the results of the columns col1 and col2 against a single value, so try to get the output in a single column.
Required output should be like
SQL > with t as (1 select col1, col2 2 double)
2 Select * from t;
COL
----------
1
2
Please suggest any solutions using regexp/connect by / or etc.
Well, then:
SQL> with t as (select 1 col1, 2 col2 from dual) 2 select nt.column_value 3 from t 4 , table(sys.odcinumberlist(col1, col2)) nt 5 ; COLUMN_VALUE ------------ 1 2
but it is overkill IMO.
-
Merge two column in single column value
Team,
I have a requirement where in I need to merge 2 column values in a single column.
e.g. I Percent_complete column in my table. and my table has only one record.
I need to ask questions that I need to store the values of percent_complete and (100-percent_complete) in a single column.
ex
Percentage complete is set to 30.
I need to select the 30 and 70 (100-30) both in a single column.
Thank you
If you mean like this?
SQL > ed
A written file afiedt.buf1 with t (select 30 as double percent_complete)
2 --
3 end of test data
4 --
5. Select decode(rownum,1,percent_complete,100-percent_complete) as percent_complete
6 t
7 * connect by rownum<=>=>
SQL > /.PERCENT_COMPLETE
----------------
30
70 -
Hi all
I have a requirement where I need to get all the records, for each record in double, I need to get a single column with null or 0.
create table a1
(
Identification number,
VARCHAR2 (100), the point
part varchar2 (100));
Insert into a1
values (1, 'ABC', 'A1');
Insert into a1
values (2, 'DEF', 'A2');
TABLE A
PART ITEM ID
1 ABC A1
1 ABC A1
1 ABC A1
DEF 2 A2
DEF 2 A2
3 DEF A2
O/P
PART ITEM ID
1 ABC A1
1 ABC 0
1 ABC 0
DEF 2 A2
2 DEF 0
3 DEF 0
Thanks in advance.
Thanks for your help FrankKalush...
This one will work.
WITH got_r_num AS
(
SELECT NVL (a1.id, a1.id) as id
NVL (a1.item, a1.item) AS element
NVL (a1.part, a1.part) IN the framework
a1.id AS a_id
ROW_NUMBER () OVER (PARTITION BY a1.id
ORDER BY NULL
) AS r_num
BY the a1
)
SELECT id
element
CASE
WHEN a_id IS NOT NULL
AND r_num = 1
THEN part
ELSE ' 0'
END in the framework
OF got_r_num
;
-
Remove ' / ' with a value of feld to create two rows
I have a table with a structure like
CREATE TABLE TEST
(
MOLDCODE VARCHAR2 (20 BYTE) NOT NULL ACTIVATE.
PRODCODE VARCHAR2 (255 BYTE),
DIAMCONTAINER NUMBER (4.1).
SEGMENT NUMBER (2.0)
)
And it contains data such as
MOLDCODE PRODCODE DIAMCONTAINER SEGMENT
ADE16920-1 CJ02A/SD51A 96 10
ADE20206 CT25A 95 8
ADE16912-1 DG31A 57 10
ADE16913 AS30A/DE28A 96 10
ADE17845 CJ24A/SD36A 96 10
I want to create another table saw which will remove / of prodcode and he will separate the values and forms two rows with the same values for the other fields.
for example.
Source: -.
MOLDCODE PRODCODE DIAMCONTAINER SEGMENT
ADE16920-1 CJ02A/SD51A 96 10
ADE16913 AS30A/DE28A 96 10
Purpose: -.
MOLDCODE PRODCODE DIAMCONTAINER SEGMENT
ADE16920-1 96 10 CJ02A
ADE16920-1 96 10 SD51A
ADE16913 AS30A 96 10
ADE16913 DE28A 96 10
Is it possible?
Need help for the same thing.Check this box:
SELECT moldcode, REGEXP_SUBSTR (procode, '[^/]+', 1, LEVEL) procode, diamcontainer, segment FROM t CONNECT BY LEVEL <= REGEXP_COUNT (procode, '/') + 1 AND moldcode = PRIOR moldcode AND PRIOR SYS_GUID () IS NOT NULL;
See you soon,.
Manik. -
Remove the clicked point of Listbox (single column)
Hello
It seems a lot of posts on clear lines of the programmatically multicolumn listbox but not the only column listboxes.
Woth the help of Martins and GerdW, helped me build a subset of a ListBox with items clicked in a reference list
Make a table of items clicked in a list
. How it adds a feature to delete just in case rather than the deletion of the entire list and do it all over again.
Thanks in advance.
Have an array of strings to the "REF" enter in the list box and store it on a shift register. When you remove an item (for example, for an event), remove this item from the list (using the removal of the table) and write back to the property Ref of the listbox. A single-column list box works exactly the same way as a multicolumn listbox.
(Excuse the broken links to properties - what happens when you create an excerpt)
Maybe you are looking for
-
How to remove a toolbar that I don't like
People, I stupidly installed "downloadfalshplayer community toolbar. It is not good. But I don't know how to uninstall it. Please, anyone?
-
HP Color LaserJet MPF M227dw: HP Color LaserJer MFP M277dw copy 2-side 2 in copy mode?
Copy 1-1-laterally and two (2) 1-side pages 2-faced but cannot copy a page that is 2-sided faces 2. My old HP LaserJet pourrait
-
can I transfer dcr-trv350 to windows vist computer?
is it possible to transfer the camcorder dcr-trv350 to windows vista to create DVDs? original software won't work on vista and pc doesnot recognize camera. RCA / usb adapter would work? and I need a capture software?
-
I want to know some info about the "friend" desktop background How can I find it?
I want to know some info about the "friend" desktop background How can I find it?
-
I have a Dell Vista Home that will not start, it seems that power does not work, I can get a new power supply so I can back up my data or do I have to upgrade and just move the hard drive to the new computer?