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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:01:03+00:00 2026-06-17T16:01:03+00:00

I have a table as shown below Col1 Col2 Col3 * $ * $

  • 0

I have a table as shown below

Col1    Col2    Col3
*         $       *
$         *       *
#         *       $
%         *       *
*         *       $
*         @       $

I want a sql query to count the number of stars(*) present in the table.

one option is to write the query in the following manner.

select ((select count(*) from star_table where col1='*') + 
(select count(*) from star_table where col2='*') +
(select count(*) from star_table where col3='*')) as count from dual.

I want to know if there is an alternative way of writing the query to get the same result.

  • 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-17T16:01:04+00:00Added an answer on June 17, 2026 at 4:01 pm
    select sum(
                 case when col1='*' then 1 else 0 end +
                 case when col2='*' then 1 else 0 end +
                 case when col3='*' then 1 else 0 end            
           ) 
    from star_table;  
    

    UPDATE: If your columns contains on character length strings, you can:

    select sum(3 - length(replace(col1||col2||col3,'*')))
    from star_table; 
    

    You asked for this 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html table like below +-------+-------+-------+-------+-------+---------+---------+---------+---------+ | col1 | col2 | col3
I have a select statement working as shown below $test = $pdo->query('Select col1, SUM(col2),
I have a table withe different columns as shown below Ref Number Service Numbers
I have table as shown below. In order to workaround one default now column
Ok I have a table in my mysql query browser like shown below: NAME:
I have a database table that has a structure like the one shown below:
I have a table structure like the one shown below: <table id=result> <tr> <td
I have one requirement as shown below : Suppose we have EMP table with
I have a table as shown below. Upon click on the edit I want
Need help with Min Function in SQL I have a table as shown below.

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.