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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:30:53+00:00 2026-06-02T14:30:53+00:00

Given : InsuranceCompanies ( cid , name, phone, address) Doctors ( did , name,

  • 0

Given :

InsuranceCompanies (cid, name, phone, address)

Doctors (did, name, specialty, address, phone, age, cid)

Patients (pid, name, address, phone, age, gender, cid)

Visits (vid, did, pid, date, description)

Where:

cid - Insurance Company code
did - doctor code
pid - patient code
vid - code of visit

And a TASK : Find doctors (did, name) with number of visits (during this year) less than average number of visits to all doctors during this year.

My attempt is:

SELECT  D.did, D. name
FROM    Doctor D,Visit V
WHERE   V.did = D.did   and   D.did = CV.did   and   CV.visits <
                (SELECT AVG ( CV.visits) 
                 FROM   (SELECT V1.did AS did,COUNT(V1.vid) AS visits
                         FROM   Visit V1
                         WHERE  V1.date LIKE '%2012' 
                         GROUP BY   V1.did) AS CV)
  • 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-02T14:30:56+00:00Added an answer on June 2, 2026 at 2:30 pm

    A BIG THANKS TO Bridge Who shared the most beautifull and user freindly SQL commands visualator ever!

    Databse Exemple : http://sqlfiddle.com/#!2/e85c7/3

    Solution using views:

    CREATE VIEW  ThisYear AS 
        SELECT v.pid,v.vid,v.did
        FROM Visits v
         WHERE v.date LIKE '%2012';
    
    CREATE VIEW DoctorsVisitCount AS
        SELECT v.did, COUNT(v.vid) as c
        FROM ThisYear v
        GROUP BY v.did;
    
    SELECT DISTINCT d.did,d.dname,dvc.c
    FROM Doctors d,DoctorsVisitCount dvc
    WHERE dvc.c < (SELECT AVG(dvc.c)
                   FROM DoctorsVisitCount dvc);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given : InsuranceCompanies ( cid , name, phone, address) Doctors ( did , name,
Given this XML: <?xml version=1.0 encoding=utf-8?> <content dataType=XML> <item type=Promotion name=Sample Promotion expires=04/01/2009> <![CDATA[
Given a table like this: [Last Name] [First Name] [DepartmentID] --------------------------------------- Doe John 1
Given a DateTime representing a person's birthday, how do I calculate their age in
Given a latitude and longitude, what is the easiest way to find the name
Given the following classes: class Department { public String Name { get; set; }
Given HTML like this: <body> <form name=myForm action=savedata.php method=post> <input type=text name=myName /> </form>
Given the following tables: create table index(name text, docid int); create virtual table docs
Given Table A Id INTEGER Name VARCHAR(50) Table B Id INTEGER FkId INTEGER ;
Given a generic attribute class: public class Attribute<T> { string Name { get; set;

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.