get custom query with nodejs sequelize with mysql - node.js

if this is my data
name
code
qnt
t
2
4
t
2
5
b
3
3
b
3
2
b
3
7
I want to get data like this
name
code
qnt
t
2
4
t
2
5
-
-
9
b
3
3
b
3
2
b
3
7
-
-
12
I mean to get all rows and total of qnt of rows that have same name and code under rows.
I have to show a table in this format

You can use WITH ROLLUP from MySQL and need to use the raw SQL query:
const rows = await sequelize.query(`
SELECT name, code, qnt
FROM table
GROUP BY name WITH ROLLUP
`, {
type: QueryTypes.SELECT
});

Related

Use other tables as conditions for custom columns

I currently have a table (Table1) in Power Query, imported from a excel in sharepoint:
Object_ID
Object
Param 1
Param 2
Param 3
...
Output
1
ObjectA
3
8
12,7
...
---
2
ObjectB
2
7
18
...
---
3
ObjectC
5,5
4
3
...
---
Which parameter goes into the custom colum "Output" should be defined by another excel in sharepoint (Table2). If it can't find it in Table2 it should just be left empty.
Table 2:
Object_ID
Output-Parameter
1
1
2
3
3
2+3 (*)
(*) The actual format ( 2+3 or 2/3 or 2;3 ...) I can change if some case is easier than others
Expected Result of Table1:
Object_ID
Object
Param 1
Param 2
Param 3
...
Output
1
ObjectA
3
8
12,7
...
3
2
ObjectB
2
7
18
...
18
3
ObjectC
5,5
4
3
...
7
Until now I just input the if conditions manually in the custom column but is there an easier and more elegant way to directly reference it to the Table 2?
Thank you for your help!

excel multiple criteria and transform horizontaly to verticaly

I have unique number of items and invoices, but one invoice can have multiple items.
A B C D
1 Invoice Items
2 1 10
3 2 20
4 1 30
idea is sort it to horizontaly via this formula
=IFERROR(INDEX($B$2:$B$8;SMALL(IF($D$2=$A$2:$A$8;ROW($A$2:$A$8)-ROW($A$2)+1);COLUMN(A1)));"")
result:
A B C D E F
1 Invoice Items Invoice Item1 Item2
2 1 10 1 10 30
3 2 20
4 1 30
But my geal is setup results horizontaly:
A B
1 Invoice Items
2 1 10
3 1 30
4 2 20
Is that even possible ?
Is your goal actually to sort on Invoice first and then on Items? If so, why just not using sort on two levels using the build in option?
Input:
Sort:
Output:
It's in Dutch but you'll get the idea :)

How to multiple column join in one column in excel (I Want Formula)

HOW TO JOIN MULTIPLE COLUMN IN ONE COLUMN
TABLE 1 TABLE 2 TABLE 3
1 2 5
2 4 3
3 5 3
4 5 1
I WANT TO
1
2
3
4
2
4
5
5
5
3
3
1
If your data is like below, enter the formula in the first row of any column and drag down until there is no value left over,
=IF(ROW()<=COUNTA(A:A),INDEX(A:A,ROW()),IF(ROW()<=COUNTA(A:B),INDEX(B:B,ROW()-COUNTA(A:A)),IF(ROW()>COUNTA(A:C),"",INDEX(C:C,ROW()-COUNTA(A:B)))))

Counting a group of columns on google spreadsheet

I have a couple of columns as shown below:
A B C D E
1 12 4 1
2 3 2 2
3 7
4 3 0 6
How would I be able to return a count of each column above so for example receive the result:
A B C D E
1 12 4 1
2 3 2 2
3 7
4 3 0 6
5 count:3 4 2 1
for each of the column. Im looking for a formula that would be able to do that in one cell(B5) returning a count for each of the columns, and avoid using fill handling as the data set is quite large
It's pretty easy, using Google Spreadsheet's functions:
=ArrayFormula(MMULT(TRANSPOSE(row(A1:A4)^0),--(len(A1:E4)>0)))
Or, if you want join them all:
=JOIN(", ",ArrayFormula(MMULT(TRANSPOSE(row(A1:A4)^0),--(len(A1:E4)>0))))

Dynamically determining range to apply formula/function in EXCEL

I need to determine the range to apply the Frequency function. Here's what the problem is. On the given sheet, I have subtotals for my data and there is a column which has "Stop" Values.
The data would look something like:
Route1
Order# Stop# Qty
001016 1 5
008912 1 5
062232 2 6
062232 3 2
069930 4 1
1000 4 3
1001 4 4
1001 5 8
1003 8 1
Route 1 Subtotal 6 35
Route2
Order# Stop# Qty
10065 1 5
10076 1 5
10077 2 6
10079 3 2
10087 4 1
10098 4 3
10109 4 4
10171 5 8
10175 8 1
Route 2 Subtotal 6 35
How do I write VBA code for calculating the distinct stop values. I need the distinct count of the stop#. Hence in the example above you can see that the total stops are 6 because 1 stop can have multiple orders and 1 route can have multiple orders/stop. Hope I am making sense here. Let me know how I would write my VBA code for this. Thanks for your help.
For the Stop Subtotal unique count, try this formula (adjust ranges as required):
=COUNT(1/FREQUENCY(B2:B10,B2:B10))

Resources