please tell me how i make a sql query for
selecting data's from a table where that data repeated 4 times in that column

Recommended Answers

All 4 Replies

to select a column in a table we use the select command the command will be select * from table name....

I would think that would be something like (using a table called Table1 with one column called "Name"):

SELECT * FROM (Select Table1.Name, Count(Table1.Name) as NumNames from Table1 group by Table1.Name)  WHERE NumNames=4

Hi,
Aggregate functions cannot be used in WHERE clause directly. Instead you can apply HAVING clause to GROUP BY clause. Try this:

SELECT Table1.Name, Count(Table1.Name) AS NumNames 
  FROM Table1 GROUP BY Table1.Name HAVING NumNames=4;

This will select all occurrences of Table1.Name that appear four times in table1

btw, if you want to use aggregate functions in WHERE clause for some reason, you need to wrap them in UDFs. UDFs can freely be used in WHERE clause (at the cost of performance).

-- tesu

please tell me how i make a sql query for
selecting data's from a table where that data repeated 4 times in that column

select [column name] from table name where (condition)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.