Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8068279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:37:00+00:00 2026-06-05T12:37:00+00:00

Ahead of this question Sqlite 3 Insert and Replace fails on more than 1

  • 0

Ahead of this question
Sqlite 3 Insert and Replace fails on more than 1 unique column

I have a table with schema,

CREATE TABLE tbl_poll ( 
    id         INTEGER PRIMARY KEY AUTOINCREMENT,
    poll_id    STRING NOT NULL,
    ip_address STRING NOT NULL,
    opt        STRING NULL,
    CONSTRAINT 'unique_vote_per_poll_per_ip_address' UNIQUE ( poll_id, ip_address )  ON CONFLICT REPLACE 
);

When I do,

select opt,count(opt) as count from tbl_poll where poll_id = 'jsfw' group by opt

Result is

opt            count
0                4
2                2 
3                2

i.e. 4 users have selected 0 option, 2 and 3 option is selected by 2 and 2 users respectively.

Is there any way so I can get a result like following

   opt            count    percent
    0                4        0.5       
    2                2        0.25 
    3                2        0.25

where percent = count / total count

If I can get total count i.e. (4+2+2 = 8 ) that will solve my problem too.

I have tried this,

   select opt,count(opt) as count from tbl_poll where poll_id = 'jsfw' 

but it doesn’t work as no of columns are not same.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:37:03+00:00Added an answer on June 5, 2026 at 12:37 pm
    SELECT opt
         , COUNT(*) AS count
         , ROUND(CAST(COUNT(*) AS REAL)/total, 2) AS percent 
    FROM tbl_poll 
      CROSS JOIN
        ( SELECT COUNT(*) AS total 
          FROM tbl_poll 
          WHERE poll_id = 'jsfw' 
        ) AS t
    WHERE poll_id = 'jsfw' 
    GROUP BY opt ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is for SQL Server 2005. I have a table with 2 columns.
Note: I realize that this is probably an open-ended question, so go ahead and
I apologize ahead of time for the length of this question...It's a little involved.
This question is just to clear some things up. Some things like this have
I am sorry ahead of time for how this question may turn out. I
This question involves Delphi and XE specifically deprecating Suspend and Resume. I have read
I know that this question might have been asked like 100 times, but, believe
(I have asked this question on the Scrapy google-group without luck.) I am trying
Before actually asking anything, I'll go ahead and say this is a theoretical question;
Go ahead and let me know if this is not possible: I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.