I'm working with an Access database and I need to concatenate different related rows into 1 row. I found a solution here and used it with great success. However I need to add extra conditions to it, it should only be done if certain other columns are equal too.
For example:
1 X Alpha
2 Y Beta
1 X Gamma
1 Z Delta
should become
1 X Alpha,Gamma
1 Z Delta
2 Y Beta
Does anyone know to do this, especially for a newbie like me?
It seems you are using the code supplied in Does MS access(2003) have anything comparable to Stored procedure. I want to run a complex query in MS acceess.
There is no reason why you should not feed in two fields as one in your sql, so an example:
SELECT Number & Letter,
Concatenate("SELECT Letter & Alpha As FirstField FROM tblTable
WHERE Number & Letter =""" & [Number] & [Letter] & """") as FirstFields
FROM tblT
Related
I'm trying to compute a new variable using 3 other variables. If all 3 conditions are positive, the new variable gives 1. My problem: if just 1 or 2 of these conditions are present, I get a value 0 when it needs to be a system missing.
In order to get SPSS to calculate a value only when you have values in all three variables you can use this:
if nmiss(E’sept_preTx, Eope’gem_preTx, TRpieksnelheid_t1)=0
DD_new=(E’sept_preTx < 10) & (Eope’gem_preTx >= 15) & (TRpieksnelheid_t1 > 2.8).
the nmiss counts the missing values, and the original calculation is carried out only if tere are none.
I'm trying to make search a bit more friendly and wanted to exploit the Levenshtein distance. This works great but if a value in a column has a length of 25 characters long, the distance to only 3 characters is too far. In this case, it performs worse than the LIKE method. I solved this by splitting all words into their own rows using regexp_split_to_table. This is nice, but it's still not working if I have multiple words as input.
For example:
Let the data look as following
id
col1
col2
1
one two
three
2
two
one
3
horse
tree
4
house
three
using regexp_split_to_table would transform this to
id
col
1
one
1
two
1
three
2
one
2
two
2
two
3
horse
3
tree
4
house
4
three
If I search for one tree, I'd like to compare one with each word but also compare tree with each word and then order by the sum of both distances.
I have no idea where to start. I also do not know if this is the best approach to do this (it seems somewhat excessive but I'm also not an expert). Maybe I'm also overthinking this. I'd appreciate a hint into the right direction :).
I have got a data set that contains 3 columns and has 15565 observations. one of the columns has got several words in the same row.
What I am looking to do is to extract a particular word from each row and append it to a new column (i will have 4 cols in total)
The problem is that the word that i am looking for are not the same and they are not always on the same position.
Here is an extract of my DS:
x y z
-----------------------------------------------------------------------
1 T 3C00652722 (T558799A)
2 T NA >> MSP: T0578836A & 3C03024632
3 T T0579010A, 3C03051500, EAET03051496
4 U T0023231A > MSP: T0577506A & 3C02808556
8 U (T561041A C72/59460)>POPMigr.T576447A,C72/221816*3C00721502
I am looking to extract all the words that start with 3Cand are 10 characters long and then append the to a new col so it looks like this:
x y z Ref
----------------------------------------------------------------
1 T 3C00652722 (T558799A) 3C00652722
2 T NA >> MSP: T0578836A & 3C03024632 3C03024632
3 T T0579010A, 3C03051500, EAET03051496 3C03051500
4 U T0023231A > MSP: T0577506A & 3C02808556 3C02808556
8 U >POPMigr.T576447A,C72/221816*3C00721502 3C00721502
I have tried using the Contains, Like and substring methods but it does not give me the results i am looking for as it basically finds the rows that have the 3C number but does not extract it, it just copies the whole cell and pastes is on the Ref column.
SQL Server doesn't have good string functions, but this should suffice if you only want to extract one value per row:
select t.*,
left(stuff(col,
1,
patindex('%3C[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%', col),
''
), 10)
from t ;
I have a technical issue with access graphs: I have a table in Access database with 4 fields: xValue, yValue, round, partOfRound
What I want: there are always 2 rounds, each round has 2 parts. I need to get a series per round per part (so from round 1 part 1, round 1 part 2, round 2 part 1, round 2 part 2) with all xValues and yValues in a chart.
But then I have an other problem:The xValue isn't a good number to show, this is needing to be this number divided by a number from an other table (see this as number in table3) where the row of table 3 equels the identifier with the identifier I use for my chart. (IDtable2=IDtable3)
The final result will be 4 lines with the data in my graph, so 4 series.
But when I use the wizard for making graphs, I can only set 1 field to the series value, so it will see a round as just 1 series instead of 2.
How do I solve this problem?
Kind regards
Kristof
What type of graph - just a column?
Concatenate the round and partOfRound fields.
Try changing the graph RowSource to:
TRANSFORM Sum(Table2.yValue) AS SumOfyValue SELECT Table2.xValue FROM Table2 GROUP BY Table2.xValue PIVOT [round] & "_" & [partOfRound];
Possible SQL to include table join to calculate the division:
TRANSFORM Sum(Table2.yValue) AS SumOfyValue
SELECT Round([xValue]/[Factor],0) AS x
FROM Table3 INNER JOIN Table2 ON Table3.PK_Table3 = Table2.FK_Table3
GROUP BY Round([xValue]/[Factor],0)
PIVOT [round] & "_" & [partOfRound];
For both queries, I had to open the graph editor (double click the graph) and from the menu click on "By Column" button to get the x values on the x axis.
I do hope round is not an actual name as it is a reserved word and should not use reserved words as names for anything.
I need to merge data into different columns of table. I need to use stored proc to merge these data.
I have a(i = 1 to x), b, c and d as parameters
a(i = 1 to x) parameters depend on the user entry...
the other thing I need to check is at
if a(y) = b
then update b and c to table 1
else delete data from table 1 and update values a(y) to b into 4 different tables
Here y is some value in between 1 to x
should i do multiple dataconnections or use one data connection and do everything in sql?? what is the best way to tackle this problem...
If second option please samples would be a great help... Just sql side would be great!!!