Counting lines in a list [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 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

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;

Sql query to find out no of boys and girls in school [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
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;

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,}$'

How to display following display table using oracle? [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
Link http://s17.postimg.org/pdftjpl1r/Event.png
I have above two table.I want to display third table using oracle. I know display those data using java,vector and other stuff.But couldn't code correct oracle code.In the above display table shows data which are >=SYSDATE.
I think it is something like this:
select e.event_name,
min(dt.start_date) as start_date,
min(dt.start_date)||'-'||max(dt.end_date) as FromTo
from event e join
date_table dt
on e.e_id = dt.e_id
group by e.event_name;
You may need use to_char() to convert date/times to the right format. You don't specify wht the types are in the data, so it is hard to say what needs conversion.