Multiple Tables in a Single Container - node.js

I'm using the GridDB Node js Connector and was wondering how I could add multiple tables in a single container while retaining data for all of the tables?
P.S. I went through the SQL documentation for GridDB, so using the JOIN command is not confusing; it is simply the cluster intiliazation. The code from the documentation is attached below:
○Inner join
SELECT * FROM employees e INNER JOIN departments d ON e.department_id=d.department_id;
id first_name department_id department_id department
------+-----------+--------------+--------------+-----------
0 John 0 0 Sales
1 William 1 1 Development
2 Richard 0 0 Sales
4 Lisa 3 3 Marketing
5 James 1 1 Development
○Left outer join
SELECT * FROM employees e LEFT JOIN departments d ON e.department_id=d.department_id;
id first_name department_id department_id department
------+-----------+--------------+--------------+-----------
0 John 0 0 Sales
1 William 1 1 Development
2 Richard 0 0 Sales
3 Mary 4 (NULL) (NULL)
4 Lisa 3 3 Marketing
5 James 1 1 Development

Related

Report two tables that are connected as foreign keys in StimulSoft

I have two data bands in StimulSoft, one of the tables is connected to the first table by a foreign key, Master table is AllTeam looks like this:
id
TeamSubject
Manager
GroupCode
DateCreate
1
Sky
Ali
120
1400/01/01
2
Gold
Saman
111
1401/10/15
3
Mersad
Hamed
220
1400/06/21
The second table is connected to the master table by the foreign key of the 'id' column
TeamMembers looks like this:
id
AllTeamID
Name
Family
MemCode
1
1
saeed
karimi
1234
2
2
ali
hasani
1289
3
2
hamed
akbari
9874
4
3
kazem
sami
7895
6
1
ahmad
barati
121212
9
1
pardis
goli
359642
I want both tables to be displayed in Stimulsoft so that after each row of the master table all the records connected to it from the second table below it are displayed.
Result should be like this
id
TeamSubject
Manager
GroupCode
DateCreate
1
Sky
Ali
120
1400/01/01
id
AllTeamID
Name
Family
MemCode
1
1
saeed
karimi
1234
6
1
ahmad
barati
121212
9
1
pardis
goli
359642
id
TeamSubject
Manager
GroupCode
DateCreate
2
Gold
Saman
111
1401/10/15
id
AllTeamID
Name
Family
MemCode
2
2
ali
hasani
1289
3
2
hamed
akbari
9874
id
TeamSubject
Manager
GroupCode
DateCreate
3
Mersad
Hamed
220
1400/06/21
id
AllTeamID
Name
Family
MemCode
4
3
kazem
sami
7895
My main problem is that how can I introduce the ID field in the first data band, that is, the master table, to the second data band as a variable?

Excel - Count based on criteria in 3 other columns

I'm looking for help in getting a count based on criteria in 3 other columns. I started to do a pivot table, but I cannot see how to add an IF statement to the distinct count there.
I need a count of each customer within the customer type, by each supplier, if the Cases > 0 for that year.
Here's a sample data set:
Supplier
Customer
Type
2019 Cases
2020 Cases
ABC
Al's Store
Package
3
2
ABC
Ben's
Package
0
6
ABC
Kroger
Grocery
2
1
ABC
Publix
Grocery
1
0
XYZ
Al's Store
Package
0
5
XYZ
Ben's
Package
4
0
XYZ
Kroger
Grocery
0
1
XYZ
Publix
Grocery
3
7
I need a result like this. My actual report will have each supplier on their own tab.
Supplier
Type
2019 Customer Count
2020 Customer Count
My Reason
ABC
Package
1
2
Al's bought in both years, but Ben's only in 2020
ABC
Grocery
2
1
Kroger bought in both years, but Publix only in 2019
XYZ
Package
1
1
Al only bought in 2020, Ben only bought in 2019
XYZ
Grocery
1
2
Kroger only bought in 2020
Thanks!

Find the total score. for each student

Hi I have a query to retrive students score in this format
Id subject class_score total_marks rank subject_type
1 MATLAB 33.80 73.30 11 Core
1 SCIENCE 39.50 83.00 4 Core
1 ENGLISH 37.60 77.60 8 Elective
1 WQP 43.90 77.40 9 Core
1 BDT 42.00 71.50 12 Elective
1 ART 47.10 84.60 2 Elective
1 COMPUTING 26.00 65.50 13 Elective
2 MATLAB 0.00 0.00 14 Core
2 SCIENCE 38.60 73.60 10 Core
2 ENGLISH 43.80 83.30 3 Elective
2 WQP 45.00 89.00 1 Core
2 BDT 41.00 79.50 6 Elective
2 ART 38.00 78.00 7 Elective
2 COMPUTING 40.80 80.80 5 Elective
I wish to calculate the overall score of each student by add the total_marks of all (Core subject + the top 3 score of the student's elective subjects) and rank them from first to last.Please can anyone assist ?Thanks
My current
use ods_sms;
SELECT student_id,sum(t.total_marks)score
FROM
(select
student_id,total_marks from tab_exam_tracker
where (subject_type='Core')
union all select t.student_id,t.total_marks from
(select student_id,total_marks from tab_exam_tracker
where subject_type = 'Elective' order by total_marks desc
limit 3) t
) t
GROUP BY student_id
But am getting wrong results
SELECT
t.id,
SUM(total_marks) AS Core_Marks,
Elective_Marks
FROM tab_exam_tracker t
INNER JOIN (
SELECT id, SUM(total_marks) as Elective_Marks
FROM (
SELECT
id,
total_marks,
IF(#id <> id, #rank:= 1, #rank:= #rank + 1) as rank,
#id:= id
FROM tab_exam_tracker,
(SELECT #id:= 0 r_id, #rank:= 0 AS r) AS a
WHERE subject_type = 'Elective'
ORDER BY id, total_marks DESC
) as b
WHERE rank <= 3
GROUP BY id
) AS e_marks ON t.id = e_marks.id
GROUP BY t.id, Elective_Marks;

Group by name and count unique values

I have an Excel file like this, where column A and B are given. I want to add column C and D that represent days. D is pretty easy, because it is always one day. C is tricky, because I want to count only "unique" days, where a branch can be one day maximum, where D counts all days.
A B C D
Row Name Branch Unique Overall
1 Jack Health 1 1
2 Jack Health 0 1
3 Jack Food 1 1
4 Jolie Tech 1 1
5 Jolie Food 1 1
6 Jolie Tech 0 1
7 Jolie Health 1 1
I need column C and D for a pivot table like this:
Branch Unique Overall
Health 2 3
Food 2 2
Tech 1 2
I also could add names as a sub position.
Branch Unique Overall
Health 2 3
-Jack 1 2
-Jolie 1 1
Food 2 2
-Jack 1 1
-Jolie 1 1
Tech 1 2
-Jolie 1 2
But that´s something, that can be done after preparing the data and what comes with the program anyway. So how can I design a formula that counts only unique branches for a data set of hundreds of rows?
Thank you!
In C2 put:
=--(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1)
Then copy down

Grouping with SubSonic 3

I have the following table "GroupPriority":
Id Group Priority
1 1 0
2 2 0
3 3 0
4 2 1
5 1 1
6 2 2
7 3 1
I would like to group these on "Group", order them by "Priority" and then get the one in each "Group" with the highest Priority with the use of linq and subsonic 3.
In this case the result would be:
Id Group Priority
5 1 1
6 2 2
7 3 1
The sql would look like this:
SELECT *
FROM GroupPriority
WHERE (Priority =
(SELECT MAX(Priority)
FROM GroupPriority
WHERE (Group = GroupPriority.Group)))
Thanks
Got the solution:
var group_query = new Query<GroupPriority>(provider);
var items = from gp in group_query
where gp.Priority ==
(from gp_sub in group_query
where gp_sub.Group == gp.Group
select gp_sub.Priority).Max()
select gp;

Resources