June 4, 2010 at 3:47 am
Posted - 06/04/2010 : 05:34:06
--------------------------------------------------------------------------------
hi all
very new to sql
i have one table, with 7 fields
reg_no name, tickets, date,
i need to sum the tickets
but when the sum reaches 250 i need to select the people in those records and email them.
any ideas how to do this. help need badly
thanks for any help in advance
table
Registration_no int
Name varchar(MAX)
Department varchar(50)
Contact_No varchar(50)
Email varchar(MAX)
Date date
No_of_TicketsReq int
Collected bit
No_of_TicketsBought int
Sample data
Registration_no Name Department Contact_No Email Date No_of_TicketsReq
1 dee edede dede ded 01/06/2010 2 null NULL
2 john test ict 3423 234324 01/06/2010 10 NULL NULL
3 dee3 efrwer ewrwe werw 01/06/2010 1 NULL NULL
4 gj gj ghj hgj 01/06/2010 5 NULL NULL
wanted output
when the running sum of no_of_ticketsreq reaches 250 i need all the records that make up that 250 by date order or by registration no
regards
deeomen
June 4, 2010 at 3:21 pm
Please provide table def and sample data in a ready to use format so we can focus on providing a tested solution instead of formatting the sample data.
Furthermore, please include your expected result based on the sample data you provided including the code you've tried so far.
If you need a guideline on how to post the data please read and follow the first link in my signature.
June 4, 2010 at 6:38 pm
deeomen (6/4/2010)
Posted - 06/04/2010 : 05:34:06--------------------------------------------------------------------------------
wanted output
when the running sum of no_of_ticketsreq reaches 250 i need all the records that make up that 250 by date order or by registration no
I suggest that you read this article by MVP Jeff Moden[/url] for handling running totals.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
July 3, 2010 at 4:42 pm
deeomen (6/4/2010)
Posted - 06/04/2010 : 05:34:06--------------------------------------------------------------------------------
hi all
very new to sql
i have one table, with 7 fields
reg_no name, tickets, date,
i need to sum the tickets
but when the sum reaches 250 i need to select the people in those records and email them.
any ideas how to do this. help need badly
thanks for any help in advance
table
Registration_no int
Name varchar(MAX)
Department varchar(50)
Contact_No varchar(50)
Email varchar(MAX)
Date date
No_of_TicketsReq int
Collected bit
No_of_TicketsBought int
Sample data
Registration_no Name Department Contact_No Email Date No_of_TicketsReq
1 dee edede dede ded 01/06/2010 2 null NULL
2 john test ict 3423 234324 01/06/2010 10 NULL NULL
3 dee3 efrwer ewrwe werw 01/06/2010 1 NULL NULL
4 gj gj ghj hgj 01/06/2010 5 NULL NULL
wanted output
when the running sum of no_of_ticketsreq reaches 250 i need all the records that make up that 250 by date order or by registration no
regards
deeomen
I'm curious... what did you end up doing on this?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply