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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:14:10+00:00 2026-05-25T16:14:10+00:00

This is probably a naughty use for sql… But here it goes…. I have

  • 0

This is probably a naughty use for sql… But here it goes….

I have a table:

Banners
--------------
BannerID
request_t0
clicks_t0
request_t1
clicks_t1
...
request_t6
clicks_t6

Using the number of requests and clicks, I calculate a ctr (clicks to impressions ratio) for each set….
ctr_t0 = clicks_t0 / request_t0 * 100

So now I have 6 separate CTRs in each row….

For output, I would like the count of how often each CTR is the highest in it’s row…

So given the set:

ctr_t0    ctr_t1    ctr_t3
------    ------    ------
 2.39%     1.24%      1.5%
  1.4%     2.46%      2.2%
  3.1%     2.45%     1.45%

I would like as my result:

ctr_t0_count    ctr_t1_count    ctr_t3_count
------------    ------------    ------------
           2               1               0

Any ideas on how to do this w/o learning a programing language? 🙂

  • 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-25T16:14:10+00:00Added an answer on May 25, 2026 at 4:14 pm
    select
    sum(case when greatest(ctr_t0,ctr_t1,ctr_t3) = ctr_t0 then 1 else 0 end) as ctr_t0_count,
    sum(case when greatest(ctr_t0,ctr_t1,ctr_t3) = ctr_t1 then 1 else 0 end) as ctr_t1_count,
    sum(case when greatest(ctr_t0,ctr_t1,ctr_t3) = ctr_t3 then 1 else 0 end) as ctr_t3_count
    from (select .... ) as t
    

    where within select there is your previous query.

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

Sidebar

Related Questions

This probably sounds like a really dumb question, but here goes....Web Services, what the
This probably has a simple answer, but I must not have had enough coffee
This probably sounds really stupid but I have noo idea how to implement jquery's
This probably sounds like a terrible idea at first glance, but here is my
Well this probably isn't specific to rails, but in my rails app, I have
This probably applies to other places, but in WinForms, when I use binding I
I known this probably goes against lots of general rules in programming, but how
Yes, this probably shouldn't bug me. But it does!! Why does XML have such
I am using Prototype.js, but this probably applies to jQuery as well: I have
This probably isn't the most common filename parsing problem, but I have a program

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.