如何获得不对特定民意调查投票的选民的数量(How to get the count of voters who don't vote on a specific poll)
我能够在民意调查中得到总票数。 但我需要得到选民没有投票的总数。 例如,选民#1仅投票给总统类别和参议员类别,选民#2仅投票给副主席和参议员。 最后,选民#3没有投票,我仍然将选民投票#3投票并留下NULL。 因此,结果应该是没有在特定类别上投票的选民数量。
PRESIDENT : 2 VICE PRESIDENT : 2 SENATORS : 1
在选民#1没有投票支持vp的情况下,选民#2没有投票支持pres,选民#3则投了空票。
这是我的表格。
Polls id | poll_title 1 | presidential election Poll_categories id | poll_id | category_name 1 | 1 | President 2 | 2 | Vice-President 3 | 3 | Senator Poll_items id | poll_category_id | item_name 1 | 1 | Obama 2 | 1 | Bush 3 | 1 | Clinton 4 | 2 | Biden 5 | 3 | Shelby 6 | 3 | Murkowski Poll_votes id | voters_id | poll_item_id 1 | 1 | 1 2 | 1 | 5 3 | 1 | 6 4 | 2 | 4 5 | 2 | 6 6 | 3 | NULL
到目前为止,这是我的查询,但我不知道接下来该做什么。 我也无法显示elections_id 3,因为它是NULL
select c.id, c.category_name, v.voters_id from poll_category c LEFT JOIN (select v.user_id, v.poll_item_id, i.poll_category_id as cat_id, i.item_name from poll_votes v LEFT JOIN poll_items i on i.id = v.poll_item_id) v ON v.cat_id = c.id WHERE c.poll_id = 1
I was able to get the total votes on my polls. But I need to get the total count where the voters didn't vote. For example voter#1 voted on president category and senator category only and voter#2 voted on vice pres and senator only. And last, voter#3 doesn't vote which i still put voter#3 on the poll votes and leave it NULL. So result should be NUMBERS OF VOTERS WHO DIDN'T VOTE ON A SPECIFIC CATEGORY.
PRESIDENT : 2 VICE PRESIDENT : 2 SENATORS : 1
Where in voter#1 didn't vote for vp, voter#2 didn't vote for pres and voter#3 sent an empty votes.
Here are my tables.
Polls id | poll_title 1 | presidential election Poll_categories id | poll_id | category_name 1 | 1 | President 2 | 2 | Vice-President 3 | 3 | Senator Poll_items id | poll_category_id | item_name 1 | 1 | Obama 2 | 1 | Bush 3 | 1 | Clinton 4 | 2 | Biden 5 | 3 | Shelby 6 | 3 | Murkowski Poll_votes id | voters_id | poll_item_id 1 | 1 | 1 2 | 1 | 5 3 | 1 | 6 4 | 2 | 4 5 | 2 | 6 6 | 3 | NULL
So far here is my query, but i don't know what to do next. I also can't show the voters_id 3 because it is NULL
select c.id, c.category_name, v.voters_id from poll_category c LEFT JOIN (select v.user_id, v.poll_item_id, i.poll_category_id as cat_id, i.item_name from poll_votes v LEFT JOIN poll_items i on i.id = v.poll_item_id) v ON v.cat_id = c.id WHERE c.poll_id = 1
原文:https://stackoverflow.com/questions/35933893
最满意答案
它与引用元素号9(基于0)相同。
等效符号将是:
&inBuf[9]
如果你想得到这个值,你可以使用
*(inBuf+9)
It is same as referencing element number 9(0 based).
An equivalent notation would be:
&inBuf[9]
If you want to get the value, you could use
*(inBuf+9)
相关问答
更多-
'^ @'在vim中意味着什么?(What does '^@' mean in vim?)[2023-09-08]
你看到的是Vim对不可打印字符的直观表示。 它的解释是:help 'isprint' : Non-printable characters are displayed with two characters: 0 - 31 "^@" - "^_" 32 - 126 always single characters 127 "^?" 128 - 159 "~@" - "~_" 160 - 254 "| " - "|~" 255 " ... -
它与引用元素号9(基于0)相同。 等效符号将是: &inBuf[9] 如果你想得到这个值,你可以使用*(inBuf+9) It is same as referencing element number 9(0 based). An equivalent notation would be: &inBuf[9] If you want to get the value, you could use *(inBuf+9)
-
什么'<>'在c ++中意味着什么?(what '< >' means in c++?)[2023-05-10]
泛型:) 阿卡“模板” 我有一个类Inserter,它有一个Inserter对象,从类数据对象集的常量调用。 然后我生成另一个名为Info的对象。 有点 :) 你有一个“插入者”类。 它的构造函数使用模板类“producer”。 您实例化“信息”类型的“生产者”。 这是一个关于模板的好教程: http://www.cplusplus.com/doc/tutorial/templates/ Generics :) Aka "templates" I had a class Inserter that had ... -
TL; DR:谁写了“在线课程”决定做95%的工作:) 据推测, StartUp类声明如下: class StartUp : public QObject { Q_OBJECT QQmlApplicationEngine & m_engine; MainViewMgr & m_mainViewMgr; public: StartUp(QObject * parent = {}); }; 由于QQmlApplicationEngine和MainViewMgr都应该在StartUp对象处于活动 ...
-
**在C中意味着什么?(What does ** mean in C?)[2023-06-06]
在这种情况下, double表示double类型的变量。 double*表示指向double变量的指针。 double**表示指向double变量指针的指针。 对于您发布的函数,它用于创建一种二维的双精度数组。 也就是说,指向双指针数组的指针,每个指针都指向一个指针数组。 In this case, double means a variable of type double. double* means a pointer to a double variable. double** means a po ... -
C ++中没有特定的**运算符,而是两个单独的星号,声明中的星号表示指针声明。 所以在宣言中 IntElement **head 参数head被声明为指向IntElement的指针。 There is no specific ** operator in C++, instead it's two separate asterisks, and asterisks in a declaration denotes pointer declaration. So in the declaration Int ...
-
分配后, **d与*w相同。 d是指向一个整数的指针; 指向它指向的整数的指针是w 。 所以*d是w , **d是*w 。 After the assignment, **d is the same as *w. d is a pointer to a pointer to an integer; the pointer to an integer that it points to is w. So *d is w, and **d is *w.
-
这意味着lambda表达式通过赋值捕获值。 另一种选择是使用[&]通过引用捕获。 这里有许多变化,而不是将它们全部列在这里,我会告诉你这个高质量的答案: 什么是C ++ 11中的lambda表达式? That means that the lambda expression captures values by assignment. Another option is to capture by reference using [&]. There are many variations on this, ...
-
/ **在c ++中意味着什么(what does /** mean in c++)[2024-02-02]
Doxygen使用这种形式的评论 - 该软件可以为源代码生成文档。 请参阅网站。 我猜你的IDE了解这一点。 This form of comment is used by Doxygen - This software enables one to generate documentation for the source code. Please see the web site. I guess your IDE understands this. -
这种符号在expressoin函数中意味着什么:* ~~(What does this notation mean in an expressoin function: *~~)[2022-07-30]
你已经猜到了! 波浪号在expression()添加一个空格。 请参阅?plotmath的表格以获取更多信息......从那里, 'x * y'并列x和y 和 'x ~~ y'在x和y之间放置了额外的空间 You've guessed it! A tilde adds a space in expression(). See the table in ?plotmath for more information ... from there, ‘x*y’ juxtapose x and y and ‘x ~ ...