首页 \ 问答 \ 如何获得不对特定民意调查投票的选民的数量(How to get the count of voters who don't vote on a specific poll)

如何获得不对特定民意调查投票的选民的数量(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
更新时间:2023-08-17 20:08

最满意答案

它与引用元素号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对不可打印字符的直观表示。 它的解释是: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)
  • 泛型:) 阿卡“模板” 我有一个类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对象处于活动 ...
  • 在这种情况下, 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, ...
  • 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.
  • 你已经猜到了! 波浪号在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 ~ ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)