WPF Datagrid Rowspan on one column depend of value - wpf

(sorry for my english)
I have a problem with my datagrid.
First, my datagrid is fill from a database, depend of a value selected in a combobox. When the SelectedValue of my combobox change the datagrid ItemsSource is refresh with good value.
For now my datagrid look like that
|---|---|---|
| A | + | 1 |
|---|---|---|
| A | - | 1 |
|---|---|---|
| B | + | 2 |
|---|---|---|
| C | - | 1 |
|---|---|---|
I would like to span row of column with number if letter are equal. Because the value of number is linked to the letter value.
To make the datagris look like
|---|---|---|
| A | + | |
|---|---| 1 |
| A | - | |
|---|---|---|
| B | + | 2 |
|---|---|---|
| C | - | 1 |
|---|---|---|

Related

SnowFlake - How to return the column that the least function value came from?

I am doing a Snowflake query where I get RANK from each column.
Output below:
| Rank_A | Rank B |
| -------- | -------- |
| 1 | 3 |
| 2 | 4 |
| 5 | 4 |
Then I do the LEAST function to get the Minimum across those columns
https://docs.snowflake.com/en/sql-reference/functions/least.html
Output below:
| Rank_A | Rank B | LEAST |
| -------- | -------- | -------- |
| 1 | 3 | 1 |
| 2 | 4 | 2 |
| 5 | 4 | 4 |
Lastly, (This is where I am not sure of) How can I make another column that returns what column the Least function came from - so what I am trying to return in this new column is like so:
Expected output below:
| Rank_A | Rank B | LEAST | Column Name of Least Value |
| -------- | -------- | -------- | -------------------------- |
| 1 | 3 | 1 | Rank_A |
| 2 | 4 | 2 | Rank_A |
| 5 | 4 | 4 | Rank_B |
I have no idea how I would go about this? any and all help would be greatly appreciated.
I do not know where to begin. I was contemplating doing this all in python before ingesting the data table?
You could use DECODE to get the first LEAST value column name:
SELECT *
,LEAST(Rank_A, Rank_B)
,DECODE(LEAST(Rank_A, Rank_B),
Rank_A, 'Rank_A',
Rank_B, 'Rank_B') AS column_name
FROM tab;
Output:
We can use a CASE expression along with the LEAST() function:
SELECT
RANK_A,
RANK_B,
LEAST(Rank_A, Rank_B) AS LEAST,
CASE WHEN RANK_A = LEAST(Rank_A, Rank_B)
THEN 'RANK_A' ELSE 'RANK_B' END AS LEAST_VALUE
FROM yourTable;
In the event that RANK_A and RANK_B have the same value, the above query would arbitrarily return RANK_A as the column with the least value.

Best way of storing enumerated fields with ability to change order Postgres

What is the best way for storing enumerated fields with ability to change its order?
Lets say my database looks like this:
| Table |
|---------------------|
| id | name | order|
| 1 | 1st | 1 |
| 2 | 2nd | 2 |
| 3 | 3rd | 3 |
| 4 | 4th | 4 |
Now, when user change order in such a away
| Table |
|---------------------|
| id | name | order|
| 1 | 1st | 1 |
| 4 | 4nd | 2 |
| 2 | 2nd | 3 |
| 3 | 3rd | 4 |
Here I would have to update all rows in this table.
I consider 2 solutions
Solution 1)
When inserting row X between for example order 2 and order 3, I would change row's X order field to 3.5, So I would choose number in the middle between adjacent orders.
Above table would look like this
| Table |
|---------------------|
| id | name | order|
| 1 | 1st | 1 |
| 4 | 4nd | 2.5 |
| 2 | 2nd | 2 |
| 3 | 3rd | 3 |
Then, after for example 16 changes I would update table and normalize all order fields, so table after normalization would be like this:
| Table |
|---------------------|
| id | name | order|
| 1 | 1st | 1 |
| 4 | 4nd | 2 |
| 2 | 2nd | 3 |
| 3 | 3rd | 4 |
Solution 2)
I also consider adding fields "next" (or "next" and "prev") to each row, but it looks for me like waste of memory.
I really dont want to update whole table every time somebody change order. What is the best way of solving this problem?

SQLite merge duplicates

I have a SQLite table, in which there are some Rows which differ in just one column.
I want to merge the entrys in this Column with a seperator (line break in my case).
So, this:
| id | block | description|
------------------------------
| 1 | a | foo |
| 1 | a | bar |
| 3 | b | cat |
| 4 | c | mouse |
------------------------------
Should become this:
| id | block | description|
------------------------------
| 1 | a | foo \r\n bar|
| 3 | b | cat |
| 4 | c | mouse |
------------------------------
I don't even have an Idea what to search for (instead of "merge", but I couldn't find anything suitable for my application), so any Input would be appreciated.
Jann
I think you are looking for group_concat():
select id, block, group_concat(description, ' \r\n ')
from t
group by id, block;

Generate variables that move information between rows in hierarchical data with spss syntax

I was wondering if you can help me with the following problem in spss syntax.
My dataset has nested structure.
Data are nested in companies, then each company has 1 or 2 bosses, but in this case I care only about boss 1. At a previous stage in time the boss graded the workers (not all of them). Now, the ID and the grade of the workers is on the row each worker.
I would like to move the information that was obtained during worker's assessment and create new sets of variables for each (worker ID and grade) on the line/row of the boss.
+---------+------+--------+--------------+---------+---------+--------+---------+
| company | boss |workerID|worker's grade|N:workID1|N:grade1 |N:work2 |N:grade2 |
+---------+------+--------+--------------+---------+---------+--------+---------+
| A | 1 | 1 | | 3 | A | 4 | A |
| A | 2 | 2 | | | |
| A | 0 | 3 | A | | |
| A | 0 | 4 | A | | |
| A | 0 | 5 | | | |
| B | 1 | 1 | | 3 | B | 4 | A |
| B | 0 | 2 | | | |
| B | 0 | 3 | B | | |
| B | 0 | 4 | A | | |
| C | 1 | 1 | | 2 | D | -1 | -1 |
| C | 0 | 2 | D | | |
I would like to move the worker's id and the grade that to the row of the boss in the NEW variables, without loosing the existing variables on workerID and worker's grade.
Basically, I will need to feed forward the information into the new variables and to the row of boss EQ 1 separately for each company.
I have no idea how to proceed with this. I assume that I need a loop that creates new variable for each worker ID that has a valid grade and then feeds forward the information from the worker's row to the boss' newly generated variables.
Any suggestions are very wellcome :-)
Take a look at VARSTOCASES (Data > Restructure)

Resize Infragistics UltraGrid to contents

How do I resize the entire ultragrid control in code to only show its contents?
i.e: I have
-----------------------------
| | | | blank |
| | | | |
| | | | |
| ------------ |
| |
| |
|____________________________|
and I want the borders to be tight to the grid
My best bet so far was to query DefaultLayout.Bands(0).GetExtent() and use that as the width of the grid.

Resources