hidrau
asked on
how can I create a rowcount in my query?
Hello everybody
I want to make a query like this:
SELECT TOP 15 * FROM TABLE
15 rows will return, but I would like a field that could by a countrow, is there any way to do this?
So I wouldl have a result like this:
1 house
2 paper
3 phone
4 chair
and so on
thanks
I want to make a query like this:
SELECT TOP 15 * FROM TABLE
15 rows will return, but I would like a field that could by a countrow, is there any way to do this?
So I wouldl have a result like this:
1 house
2 paper
3 phone
4 chair
and so on
thanks
ASKER
2005
ASKER
no, I can't use a store proc
SELECT Count(field1) AS Count, Field1
FROM (select SELECT TOP 15 * FROM TABLE)
GROUP BY field1
FROM (select SELECT TOP 15 * FROM TABLE)
GROUP BY field1
oops,
here's the soln.
SELECT Count(field1) AS Count, Field1
FROM (SELECT TOP 15 * FROM TABLE)
GROUP BY field1
here's the soln.
SELECT Count(field1) AS Count, Field1
FROM (SELECT TOP 15 * FROM TABLE)
GROUP BY field1
ASKER
I am having this error
Incorrect syntax near the keyword 'GROUP'.
Incorrect syntax near the keyword 'GROUP'.
its working fine at my end
select count(field_name), field_name from (SELECT TOP 15 * FROM tablename) group by field_name
in the above query, just replace the
field_name
that i suppose it
ItemType
in your table
and update the tableaname to the name of your table
select count(field_name), field_name from (SELECT TOP 15 * FROM tablename) group by field_name
in the above query, just replace the
field_name
that i suppose it
ItemType
in your table
and update the tableaname to the name of your table
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect this solution :))
Thanks very much
Thanks very much
can you put the query into a stored procedure?