find student name less than 50 attendance [closed] - sql

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a student table where column is name, attendance, and date in which data is entered everyday for the students who attend the class. For example if a student is absent on a day, entry is not made for that particular student for that day.
Finally. I need to find out students name whose attendance less than 50.

You can use GROUP BY and HAVING statements for this.
SELECT name FROM student GROUP BY name HAVING COUNT(*) < 50;
Please note that above query is not tested.

You have to use GROUP BY clause to aggregate similar student in table and HAVING check your condition, to get your desired output.
SELECT name, count(name)
FROM student
GROUP BY column_name
HAVING count(name)<50;
I hope this will help to solved your problem.

SELECT name
FROM StudentsTable
WHERE COUNT(name) < 50

Related

Hi guys i'm an SQL beginner and i'm having a hard time understanding it could u explain this line for me [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 months ago.
Improve this question
SELECT DISTINCT CITY FROM STATION WHERE MOD(ID,2)=0 ORDER BY CITY ASC;
SELECT DISTINCT CITY FROM STATION
Primary command to select data from the database. It is asking to select CITY from the table STATION whose data is unique. Thus, no duplicates are produced in result.
WHERE MOD(ID, 2) = 0
Only select those that have an even number ID.
ORDER BY CITY
Sort the results with respect to CITY names.
ASC
Sort in ascending order; which means that cities with names starting with A will come before those that have Z as first letter.

How to count mention in one day [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am try to understant how to make a table that tells me in which specific day were written the most mentions about the persons in my table.
SELECT
person,
COUNT(1) AS count_mentions,
COUNT(DISTINCT current_date) AS mention_per_date,
FROM
`aesthetic-honor-311413.big_data_alon_peled_2021.israel_media_person`
GROUP BY
person
ORDER BY
current_date asc
LIMIT
10;
EXPECTED RESULT:
person mention_per_date
Tomer 24
Shalev 18
Yosef 15
Eran 15
Gal 11
(Fictive names and numbers)
I am try to understant how to make a table that tells me in which specific day were written the most mentions about the persons in my table.
For this question, I would expect a query like this:
SELECT person, date, COUNT(*)
FROM `aesthetic-honor-311413.big_data_alon_peled_2021.israel_media_person`
GROUP BY person, date
QUALIFY ROW_NUMBER() OVER (PARTITION BY person ORDER BY COUNT(*) DESC) = 1;
This returns the date that most frequently occurs for each person. You don't mention the name of the date column, so this just uses date.

making a sub-query FROM two tables [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
SELECT staffNO, name, surname, position
FROM Staff s, Branch b
WHERE s.branchNo = b.branchNo AND city = 'London';
I have tried to make the above SQL code into a sub-query and I'm not getting anywhere. Im a beginner in SQL, how do I go about it?
The equivalent query with a sub-query and IN clause would look like this:
SELECT staffNO, name, surname, position
FROM Staff s
WHERE s.branchNo IN (
SELECT b.branchNo
FROM Branch b
WHERE b.city = 'London'
);
This of course assumes that staffNO, name, surname, position are all available as fields on the Staff table. If any of those fields come from Branch then you do need to use the JOIN syntax instead.

I need to print those entries which are being repeated based on ID column [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
have a table EMP having two columns ID, Name
EMP contains lots of entries, obviously, repeated entries.
I need to print those entries which are being repeated, but, i don't have to look on NAME column, on the basis of id only i want to print the repeated entries.
Please help me out. Thanks in advance.
To display all the repeated ids:
SELECT ID
FROM EMP
GROUP BY ID
HAVING COUNT(*) > 1
To also print the names:
SELECT ID, NAME
FROM EMP
WHERE ID IN
(
SELECT ID
FROM EMP
GROUP BY ID
HAVING COUNT(*) > 1
)

How to find rows with similar data as a specific row in sql [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Let me make it clear -
I have a table with information such as CourseID, Semester, GPA
I need to find all the CourseID's that have the same GPA(and some more fields) as CourseID='999'
I would also like a solution with AND without nested SELECT
Thanks!
So I have to find all the courseCode that has the same GPA and FailPerc as (Code 999, Year 2011, Sem B, Date 2)
Hope it's more clean now
this might work...
select c1.*
from course c1
inner join course c2 on c1.pga= c2.pga
where c2.courseid = 999
and c1.courseid <> c2.courseid
with subselects
select c1.*
from couser c1
where pga = (select pga
from course c2
where c2.courseid=999)
and c1.courseid <> 999
Before you run any query you need to somehow retrieve the data for the original data row. Unless you're writing your SQL for something like MS Access and can use domain functions like DLOOKUP(), I don't see any other way how you can get this information. This means, you need at least 2 SELECT queries and they must be nested.