I'm a total beginner. I have this piece of SQL code:
SELECT Red_tag.Zglaszajacy
From Red_tag
UNION
SELECT Red_tag.Interweniujacy
From Red_tag
SELECT Count(Red_tag.Zglaszajacy) AS PoliczOfZglaszajacy, Red_tag.Interweniujacy AS PoliczOfInterweniujacy
FROM Red_tag
Union works, but I get "Syntax error of FROM". How do I get the output like this?
|Zglaszajacy&Interweniujacy|CountOfZglaszajacy|CountOfInterweniuj?cy|
EDIT Seems like its more complex than I thought. Zglaszajacy and Interweniujacy are sets of people. These two groups also overlap (about 30% of people have records in both columns). So there are cases when the same person has 3 records in Zglaszajacy and 7 entries in Interweniujacy. That is why I need to Union this two groups and then show two cumulated counts for each man. Im not sure if I explained it well, so here's a draft:
|Union of Zglaszaj?cy and Interweniujacy |Count of Zglaszajacy| Count of Interweniujacy|
---------------------------------------------------------------------------------------
|John Doe | 3 | 5 |
|Tom Smith | NULL | 1 |
See Question&Answers more detail:os