Concatenate fields and eliminate all spaces [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have to concatenate 10 different fields in the same table. After the field concatenated, I need to eliminate the space between all characters. 30,000
records.
CUSTOMER # FIELD 1 FIELD 3 FIELD 4 FIELD 5 FIELD 6 FIELD XX
,TO BE OR NOT, /THAT IS/ /THE Q/ OR NOT THE_ QUESTION
So, it would like like:
,TOBEORNOT,/THAT IS//THEQ/ORNOTTHE_QUESTION

With concat and replace:
select
replace(concat(field1, field2,....), ' ', '')
from customer
To count the characters use len:
select
len(replace(concat(field1, field2,....), ' ', '')) counter
from customer

Related

Counting word frequency [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am trying to sum the frequency of the words cumulatively in PostgreSQL
Here's my table (example)
I need sum accumulative frequency for same words, for example the expected results is:
resize (100 + 85) = 185
trabajar (75 + 73) = 148
partir (64) = 64
How can I make the query?
you need to use GROUP BY :
SELECT
word
, SUM(frecuency)
FROM tablename
GROUP BY word

I need a part of a field [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Fieldname: DCCD
Characters in field: BAS XXXX 290 B2D explanation
I need the XXXX and want to place them in a seperate column.
The first group (ex. BAS) are always 3 characters
The The XXXX can have 2, 3 or 4 characters
The third group have 2 or 3 karakters
Between the groups there's always a space (spatie)
I got this code but it doesn't work. Can someone please help me. I don't know anything about this and I speak dutch :-)
LEFT(RIGHT([DCCD], (LEN([DCCD]) - SEARCH(" ", [DCCD]))), SEARCH(" ", RIGHT([DCCD], (LEN([DCCD]) - SEARCH(" ", [DCCD])))))
Use CHARINDEX() to find the ' ' in a string, start looking at position 5. Use SUBSTRING() to return from position 5.
substring(DCCD, 5, CHARINDEX(' ', DCCD, 5) -5)

SQL Server 2000: how to replace a entry with only the last 2 characters [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a table in a SQL Server 2000 database with a column with several entries like 01-03, 04-05. The first 2 digits are the room number and the last two digits are the bed number.
I want to replace the 01-05, 03-07 etc. with only the bed number. So only the last two charcters have to be in the column.
How do I accomplish this?
Sample data is:
In the column [Bed] with values:
22-01
08-01
09-03
01-16
Result has to be:
01
01
03
16
RIGHT should solve your problem:
SELECT RIGHT(RTRIM(Bed), 2) FROM tbl

How To Remove Space From Middle Of String [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Trying to get rid of a space.
Current Results:
P O BOX 140
Desired Results:
PO BOX 140
--This script did not work
update table
set column= replace(column, 'P O', 'PO')
from table
Something simple if the space is always the 2nd position....
take the left most character add the right most characters -1 for first letter and -1 for the space.
Select left('P O BOX 140',1) + right('P O BOX 140',len('P O BOX 140')-2) as NoO
...
WHERE UPPER(FieldText) Like 'P O%'
http://sqlfiddle.com/#!6/2a2dd/4/0
you could add some where clause limits to ensure the first character is P and the 3rd is O as well..

Select a part of a selected item in sql [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How can I possibly select a part of a row data in MS Sql?
ex. Charmina (Female)
All I want to select is the Female not the whole Charmina (Female)
Try this
select substring('Charmina (Female)',
charindex('(','Charmina (Female)')+1,
LEN('Charmina (Female)')-charindex('(','Charmina (Female)')-1)
or
select stuff('Charmina (Female)',1,charindex('(','Charmina (Female)')-1,'')
You may Use SUBSTRING to get sub sequences of strings
SELECT SUBSTRING( your_Raw ,start , length ) AS Alias
FROM Your_Table