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
 Transact-SQL (2000)
 Query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-08-08 : 07:40:03
Kathy writes "Can any one please help me in creating query


Actual Data in database
ID Name Award Note
91 Maxine Ace Award Give on date 23rd February.
91 Maxine Ace Award Give on date 27th January.
91 Maxine Meal Voucher Give on date 5th June.
91 Maxine Meal Voucher Give on date 8th August.
92 Collette Ace Award Give on date 2nd January.
92 Collette Ace Award Give on date 3rd March.
92 Collette Ace Award Give on date 5th July
92 Collette Ace Award Give on date 9 April
92 Collette Meal Voucher Give on date 8th November.
92 Collette Meal Voucher Give on date 7th June.
92 Collette Meal Voucher Give on date 4th July.


Required Data
ID Name Award No of Times Note
91 Maxine Ace Award 2 Give on date 23rd February.Give on date 27th January.
91 Maxine Meal Voucher 2 Give on date 5th June.Give on date 8th August.
92 Collette Ace Award 3 Give on date 2nd January.Give on date 3rd March.Give on date 5th July
92 Collette Meal Voucher 3 Give on date 8th November.Give on date 7th June.Give on date 4th July.

Thanks,"

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-08-08 : 09:18:40
something like
select ID, Name, Award, count(*) as [No of Times], <concatenate the Note >
from table
group by ID, Name, Award

and refer to here on how to concate the Note in rows to column


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-08 : 12:43:39
Learn SQL

http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -