Accounts And Transactions
SAMPLE SELECT SQL- USING TEMPORARY TABLES
Temporary table at session level (one #) and Global level (two ##)
A session-level temporary table (#) only exists as long as the session in question exists. This temporary table remains accessible on the database server only at the level of this session in question for the user who created it.

A temporary global table (##) only exists as long as the session in question exists. This temporary table remains accessible on the database server for all users who have access to the server as long as the session in question exists.

A common technique for using temporary tables is in the scenario of generating large reports, or in the scenario of Data Mining

 Temporary tables are created in tempdb. The name "temporary" is slightly misleading, for even though the tables are instantiated in tempdb, they are backed by physical disk and are even logged into the transaction log. They act like regular tables in that you can query their data via SELECT queries and modify their data via UPDATE, INSERT, and DELETE statements. If created inside a stored procedure they are destroyed upon completion of the stored procedure. Furthermore, the scope of any particular temporary table is the session in which it is created; meaning it is only visible to the current user. Multiple users could create a temp table named #TableX and any queries run simultaneously would not affect one another - they would remain autonomous transactions and the tables would remain autonomous objects.

 
IMPORTANT: 
There is also the possibility to use temporary table variables, however, we will not explore this theme in this example component at this time.
  
SAMPLE USING TEMPORARY TABLE SESSION LEVEL
Name
Account Number
Balance
Is Active
Count Itens
Amount
Dennis Wise
27209427
52365
True
4
590
Edward Williams
49217033
8320
True
4
402
Andrea McCarthy
35692671
50001
False
4
321
Maggie Todd
26293664
4429
True
4
367
Fannie Woods
66139041
3420
True
3
591
Willie Gibbs
70302466
17724
True
3
156
Dale Quinn
49507570
81025
False
3
334
Erik Hubbard
69224662
37226
True
3
314.5
Ivan Gill
63266225
55012
False
2
334
Robert Holland
85142770
33914
True
2
607
Seth Lucas
96336512
1594
True
2
215
Myra Carson
39343020
58311
False
2
60
Bradley
7209427
74523
True
0
0
Bernard
9217033
74523
True
0
0
Bruno
5692671
74523
True
0
0
Britney
6293664
74523
True
0
0
Camila
6139041
74523
True
0
0
Charles
3024663
74523
True
0
0
Casey
9507570
74523
True
0
0
Carl
9224662
74523
True
0
0
Emily
3266225
74523
True
0
0
Emily
5142770
74523
True
0
0
George
6336512
74523
True
0
0
Haley
9343020
74523
True
0
0
Hamilton
7209427
74523
True
0
0
Harrison
9217033
74523
True
0
0
Hannah
5692671
74523
True
0
0
Justin
6293664
74523
True
0
0
Jacob
6139041
74523
True
0
0
Janice
3024663
74523
True
0
0
Jerome
9507570
74523
True
0
0
Galter
0
0
True
0
0
Rui testeq
0
0
True
0
0
OSDC 2021 Teste
0
0
True
0
0
SAMPLE USING TEMPORARY TABLE GLOBAL LEVEL
Name
Account Number
Balance
Is Active
Count Itens
Amount
Dennis Wise
27209427
52365
True
4590
Edward Williams
49217033
8320
True
4402
Andrea McCarthy
35692671
50001
False
4321
Maggie Todd
26293664
4429
True
4367
Fannie Woods
66139041
3420
True
3591
Willie Gibbs
70302466
17724
True
3156
Dale Quinn
49507570
81025
False
3334
Erik Hubbard
69224662
37226
True
3314.5
Ivan Gill
63266225
55012
False
2334
Robert Holland
85142770
33914
True
2607
Seth Lucas
96336512
1594
True
2215
Myra Carson
39343020
58311
False
260
Bradley
7209427
74523
True
00
Bernard
9217033
74523
True
00
Bruno
5692671
74523
True
00
Britney
6293664
74523
True
00
Camila
6139041
74523
True
00
Charles
3024663
74523
True
00
Casey
9507570
74523
True
00
Carl
9224662
74523
True
00
Emily
3266225
74523
True
00
Emily
5142770
74523
True
00
George
6336512
74523
True
00
Haley
9343020
74523
True
00
Hamilton
7209427
74523
True
00
Harrison
9217033
74523
True
00
Hannah
5692671
74523
True
00
Justin
6293664
74523
True
00
Jacob
6139041
74523
True
00
Janice
3024663
74523
True
00
Jerome
9507570
74523
True
00
Galter
0
0
True
00
Rui testeq
0
0
True
00
OSDC 2021 Teste
0
0
True
00
Click here to see your activities