Sql query to find out no of boys and girls in school [closed] - sql

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Sql query to find out no of boys and girls in school
is it correct
select count(*)
from schooldata
group by sex;

You need sex in select as well, otherwise you can't tell which is which.
select sex, count(*) from schooldata group by sex;

Related

Oracle SQL Query COUNT [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Oracle SQL query:
TABLES
MovieInfo (mvID,title,rating,year,length,studio)
GenreInfo(mvID*,genre)
DirectInfo(mvID*,Director)
Problem: List all genre in the database and how many movies are listed against each genre. List the genre in order of most common to least common.
SELECT genreinfo.genre,count(1) as popularity
FROM
GenreInfo , MovieInfo
WHERE MovieInfo.mvID = GenreInfo.mvID
GROUP BY genreinfo.genre
ORDER BY popularity desc;

finding the word like in a sql query [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a string like this:
i would like to go to office, and i would like to go to market
My question is: how many times the word like occurs in the string?
Please write a query.
You can use regexp_count:
SELECT REGEXP_COUNT('i like to go , and i would like market', 'like')
FROM DUAL;
The word "like" occurs twice in the string you posted.
The following is a query:
SELECT *
FROM SOME_TABLE
WHERE SOME_VALUE = SOME_OTHER_VALUE
Share and enjoy.

How to be a command in SQL using LIKE? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to select records where a field (varchar (45)) contains one and only one letter x and the field length is greater than 20
In MySQL you can do:
SELECT * FROM tablename WHERE fieldname REGEXP '^[x]{20,}$'

Search for all strings that have a space in between using SQL query [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Take for example I have entries like 'Jhon Abraham','Hrithik Roshan' and 'Jimmy'.
Then, the output should fetch me the first two entries i.e. 'Jhon Abraham' and 'Hrithik Roshan'.
SELECT columnName
FROM table
WHERE trim(columnName) LIKE '% %'
SELECT col_name FROM table_name WHERE col_name LIKE '% %';

Counting lines in a list [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I have a list of objects and colors; each object has a color. I want to create a query that will count how many objects I have of each color.
What function should I use?
You might write a query like this:
SELECT COUNT(color) AS cnt, color FROM YourTable
GROUP BY color
SELECT Color, Count(Objects)
FROM myTable
GROUP BY Color