I want to automate moving values from one row to other by using function like RIGHT, the thing is i need to take from one col (row) 2 last letters and put them into the other column but in the same id/row. ScreenShots should clear some things up.
You can run an update query.
EDIT (Thanks to #Applecore):
UPDATE tableName SET KodNrProjektu=RIGHT(NumerProjektu,2)
Before:
After:
Related
I have a csv file and I need to delete all even lines (example: line 2, line 4, line 6 ecc.). They are over 7000. It's possible to do with a single command or function in Libreoffice Calc?
For example, if the data is in column A, then enter this formula in B1 and fill down.
=INDIRECT(ADDRESS(ROW()*2-1;1))
Excellent A (as usual) from #JimK but might not adapt too well if the rows to be deleted contain data in many columns. So though not a single command or function (more a process that should at least achieve the result, if not in the preferred way):
Fill as much of a (spare) column as required with:
=ISODD(ROW())
then filter to select FALSEs and delete these rows. The helper column may then also be deleted.
(Open Office Calc) I have two rows of the same length, containing letters.
Suppose the two rows are A1:Z1 and A2:Z2.
I want to check if A1=A2, B1=B2, ... Z1=Z2 and output in one cell how many of these conditions are true.
I tried using COUNTIF but the condition can only refer to a fixed cell, not to a "moving" cell. In this case I would like to be able to write something like "COUNTIF(?1= ?2)" where "?" is the column index.
Any ideas?
Please try:
=SUMPRODUCT(A1:Z1=A2:Z2)
I have a table with ~200,000 rows. There are three different phone number columns and the data in them is not all formatted the same. I'd like to remove any value that is not a number and update every cell.
For instance, (412)641-5892 becomes 4126415892.
I found this STRIP_NON_DIGIT() function here. I can use that in my SQL queries and it works properly, but it takes a minute to return a result. I'd like to run a mass UPDATE across the entire table, but not sure what the syntax is for that.
Something like this is what I'm going for.
UPDATE leads
SET phone = STRIP_NON_DIGIT(phone),
mobile_phone = STRIP_NON_DIGIT(mobile_phone),
home_phone = STRIP_NON_DIGIT(home_phone)
Turns out the answer was the pseudo code that I wrote!
I have interim results table where each question in a quiz is scored individually. Once that's done, I want to add up certain fields of all rows into a single row and then add the row to a adminresults table. I am able to do this in a two steps but not sure how to combine it into a single query.
This is my code to combine the specific fields from the interimr table:
select sum(TotalScore),
sum(ActualScore),
GROUP_CONCAT(Scorebreakdown),
GROUP_CONCAT(Feedback)
From interimr
This is my code to enter specific fields into the adminresults table:
INSERT INTO `adminresults`(`TotalScore`, `ActualScore`, `Scorebreakdown`, `Feedback`)
VALUES (50,40, 'First try', 'First try')
I have hyperlinked a pics of the structure my tables. Thanks
I am assuming that by "add to" you mean insert into. If you mean "update a single row in", then the syntax is a bit different.
Just use insert . . . select syntax:
INSERT INTO `adminresults`(`TotalScore`, `ActualScore`, `Scorebreakdown`, `Feedback`)
select sum(TotalScore), sum(ActualScore), GROUP_CONCAT(Scorebreakdown), GROUP_CONCAT(Feedback)
From interimr;
Note: you might want additional information such as the date/time of the insertion, but that is outside the scope of your question.
I have a table with rows and where one field is a bit-value with 7 digits.
Suppose I have a procedure where I want to select all rows where this bit field equals '0101010', this is easily done by select * where .... and so on.
But: how do I do if I want to allow one/multiple digits of the digits to be either 1 Or 0, i.e I want to get all rows where the bitfield has an entry on the form 1001*1* where the * can be either 1 or 0. So, in this case I would like all entries where the bit field is 1001010, 1001011, 1001110 or 1001111.
select * from TABLE where bit_field in (1001010, 1001011, 1001110, 1001111) would probably work in this example, but if I want to use only the string '1001*1*' as input to the procedure, what then?
.
Any help is very appreciated.
Thanks,
Niklas
Edit: I've tried this: select * from table where field like bit'\\\0'; for getting all entries of the form **0, but that didn't work...
Edit2: It turned out it vas a bit-field, not binary... problem still remain though.
Not a direct answer to your question, per se', but an alternative approach. You mentioned that you didn't want to convert to individual columns because of legacy code. If you do want individual columns and the only thing holding you back is the legacy code, consider the following.
You could add columns for the options and use insert/update triggers to populate them OR you could create a view that splits the bits into separate columns. For new development, you can code to the new columns. Over time, as you modify legacy code you can change it to the new approach. When all the "read" legacy code has been changed, the last step is to change the "write" code to use the new columns rather than the bit column and remove the triggers.
I have a SQL Fiddle demonstrating this here. Note that I only included an insert trigger for brevity.