Question: Hey guys I been reading about pointers, structs and data structures in C over the last couple of days. Now I am trying to implement a Hash Table in C by following along this tutorial: <https://www.tutorialspoint.com/data_structures_algorithms/hash_table_program_in_c.htm>

However tutorialspoint is assuming there will only be 1 hash table and it is making it global. Furthermore, tutorialspoint does not take into account collisions.

I want to make a struct to not limit myself to a single hash table and I plan to incorporate chaining (to deal with collisions) with a linked list. I have the following:

```
typedef struct node {
    int key;
    int data;
    struct node* next;
} node;

typedef struct linkedList{
    node* head;
    node* tail;
    size_t size;
} linkedList;

typedef struct hashTable{
    //perhaps an array of linked list? This member is what I need help with
    //And other potential members I am overlooking
    size_t size
} hashTable;

```

Some things that I need to explain:

1. The node struct serves as a pair of key/data and it has a pointer to the next pair that has the same hash code. All nodes with the same hash code will be in the same linked list.
2. The linkedList struct is represents a linked list that will eventually become a row in the hash table. All linked lists will be a row in the hash table.
3. The hashTable struct contains all the linkedLists.

How can I make an array of the linkedList struct in my hashTable struct? Is there other members I am overlooking in my 3 structs?

Any help is appreciated!

P.S. I plan to use the methods I wrote in my Linked List program. Here is a link to an early version of it: <https://codereview.stackexchange.com/questions/176904/my-linked-list-implementation-in-c>

Answer: 
You could try below

```
select bx.id, recieved, sum(c.sent) sent from
(
SELECT a.id, sum(b.received) recieved
from a 
INNER JOIN b 
ON a.id=b.uid
group by a.id
) bx
INNER JOIN c 
ON c.uid=bx.id 
group by bx.id, bx.recieved;

```

**[>>>Demo<<<](http://sqlfiddle.com/#!4/4dea9/10)**
This gets rid of the subquery, but introduces something else you might not want:

```
( SELECT  uid, 'Received' AS direction, SUM(received) AS HowMany
      WHERE  uid = 1
      GROUP BY uid )
UNION ALL
( SELECT  uid, 'Sent' AS direction, SUM(sent) AS HowMany
      WHERE  uid = 1
      GROUP BY uid )

```