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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:32:56+00:00 2026-06-08T23:32:56+00:00

SELECT COUNT(ID) AS RANK1 FROM `db_ranking` WHERE `sid`=2 AND `rank`=1 UNION SELECT COUNT(ID) AS

  • 0
SELECT  COUNT(ID) AS RANK1 FROM `db_ranking` WHERE `sid`=2 AND `rank`=1
UNION
SELECT  COUNT(ID) AS RANK2  FROM `db_ranking` WHERE `sid`=2 AND `rank`=2
UNION
SELECT  COUNT(ID) AS RANK3  FROM `db_ranking` WHERE `sid`=2 AND `rank`=3
UNION
SELECT   COUNT(ID)  AS RANK4  FROM `db_ranking` WHERE `sid`=2 AND `rank`=4
UNION
SELECT COUNT(ID) AS RANK5 FROM `db_ranking` WHERE `sid`=2 AND `rank`=5

I want to present every SELECT result in a column..

So I want to have 5 columns, each column has got a count of ID..

so it should be like that

RANK1 RANK2 RANK3 RANK4 RANK5
  0     3     5     6     7

I am not getting it now..and I dont know why

  • 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-08T23:32:59+00:00Added an answer on June 8, 2026 at 11:32 pm

    the below works fine ..

      select
        (SELECT  COUNT(ID) AS RANK1 FROM `db_ranking` WHERE `sid`=2 AND `rank`=1) as Rank1,
        (SELECT  COUNT(ID) AS RANK2  FROM `db_ranking` WHERE `sid`=2 AND `rank`=2) as rank2,
        (SELECT  COUNT(ID) AS RANK3  FROM `db_ranking` WHERE `sid`=2 AND `rank`=3) as rank3,
        (SELECT   COUNT(ID)  AS RANK4  FROM `db_ranking` WHERE `sid`=2 AND `rank`=4) as rank4,
        (SELECT COUNT(ID) AS RANK5 FROM `db_ranking` WHERE `sid`=2 AND `rank`=5) as rank5
        from dual
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do SELECT count(*) FROM users where created_at within 3 days ago
select * from ( select year, week, salesperson, count(*) as transactions, rank() over(partition by
I have been doing this for quite some time: SELECT COUNT(*) AS 'Rank' FROM
SELECT COUNT(`t`.id) FROM `product` `t` INNER JOIN `category` `c1` ON ( `c1`.id ='15' )
SELECT * FROM( (SELECT count(DISTINCT RECEPIENT_ID) as NoOfUsers, TO_CHAR(ACTN_TAKE_DATA_TM,'YYYY-MM-DD') as accDate FROM ALRT_PLATFORM_ALRT_HSTRY where
TOPIC_COUNT_SQL = SELECT COUNT(*) FROM topics_topic WHERE topics_topic.object_id = maps_map.id AND topics_topic.content_type_id = %s
SQL : SELECT COUNT(usr.id) as `total_results` FROM users as usr LEFT JOIN profile as
Example: select count(*) from my table where column1 is not null and (column1 =
i develop this code: SELECT COUNT(NewEmployee.EmployeeID), NewEmployee.EmployeeId,EmployeeName FROM NewEmployee INNER JOIN NewTimeAttendance ON NewEmployee.EmployeeID
i have this SELECT COUNT(1) cnt, a.auther_id FROM `posts` a LEFT JOIN users u

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.