Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 simple SQL query (inter dependency)

Author  Topic 

ashangel
Starting Member

3 Posts

Posted - 2002-06-18 : 06:21:50
im currently stumped on this. any help is greatly appreciated.
this is for SQL snippets that will be implemented in an asp page.
assuming i have a table which looks like this..

TBitem (table)
id co item (columns and sample values)
1 a_co. box
2 a_co. box
3 c_co. box
4 a_co. file
5 b_co. cd
6 b_co. cd
with almost 'unlimited' item type . this is where the dependency occurs coz i cant tell how many 'types' are there available.


now i want to do select so that the returned result would be like this. (from the supplied /existing values)

co item count
a_co. box 2
a_co. file 1
b_co. cd 2
c_co. box 1


order by co,item,count and preferably in a single sql select statement.

many thanks

ash

rksingh024
Yak Posting Veteran

56 Posts

Posted - 2002-06-18 : 06:33:28
select co, item, count(*) as count from tbitem
group by co, item
order by co, item, count

Ramesh

Go to Top of Page
   

- Advertisement -