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 5934953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:11:10+00:00 2026-05-22T15:11:10+00:00

In the following query, the answer of 1/2 is always zero while it should

  • 0

In the following query, the answer of 1/2 is always zero while it should be 0.5. Can you please tell me how to convert the two int columns into float/double?

SELECT 1/2, total, sb_ondate, likes
  FROM (
      SELECT sb_ondate, COUNT(*) AS total,
             STRFTIME("%w",sb_ondate) AS weekDay,
             COUNT(CASE WHEN sb_reaction = 'like' THEN sb_id END) AS likes
        FROM diet
    GROUP BY weekDay) AS f;

Thanks.

  • 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-05-22T15:11:11+00:00Added an answer on May 22, 2026 at 3:11 pm

    Cast one of the two divisors as a real:

    SELECT 1 / CAST(2 AS REAL),...
    

    Sample interactive Python session:

    >>> import sqlite3
    >>> c = sqlite3.connect(':memory:')
    >>> c.execute("create table t (a int,b int);")
    <sqlite3.Cursor object at 0x7f9b0e9539d0>
    >>> c.execute("insert into t values (1,2)")
    <sqlite3.Cursor object at 0x7f9b0e953ad8>
    >>> conn.execute("select a / cast(b as real) from t").fetchone()
    (0.5,)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I convert the following SQL statement into Lambda Expression or Linq Query?
The following query works as long as I can add DataRelations. However, the relation
I have the following query to retrieve customers who answer YES to a particular
Please copy and run following script DECLARE @Customers TABLE (CustomerId INT) DECLARE @Orders TABLE
How to get valid value from the following query SELECT Answer FROM table WHERE
I tried the following query but it doesn't give the answer that I need
After the excellent answer by Alexandre GUIDET, I attempted to run the following query:
Following query is used for Getting Categories and one news for each category. How
The following query returns strange results for me: SELECT `Statistics`.`StatisticID`, COUNT(`Votes`.`StatisticID`) AS `Score`, COUNT(`Views`.`StatisticID`)
The following query does what I'd like it to do, however, I have no

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.