Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a column customer_of_today in ado project it store total number of customer, i want to store serial number from 1 upto last customer of the day. And next day it should also start from 1. And every day this same prosess should be follow. What should i do, plz help me

[edit]SHOUTING removed - OriginalGriff[/edit]
Posted
Updated 5-Mar-13 4:57am
v2
Comments
OriginalGriff 5-Mar-13 10:58am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.
[no name] 5-Mar-13 10:58am    
Seems kind of pointless but if you want to do this then just add 1 to the previously saved value. Then the next day, start over from 1.
Mostafa Metwally 5-Mar-13 11:07am    
Don't make it identety

Example stored procedure:
SQL
CREATE PROCEDURE GetClientIDForDay()
AS
BEGIN
    DECLARE @aDay DATE
    DECLARE @CId INT

    SET @aDay = GETDATE()
    SELECT @CId = MAX(COALESCE([customer_of_today],0))
    FROM YourTable
    WHERE [SalesDate] = @aDay


    RETURN @CId
END


Probably you need to make query conditional on customer number.
 
Share this answer
 
v2
Hi,
Before you save entries into database, get the count of the entries for that day, check on google for "SQL COUNT". when you get the count of entries in the db for that selected day, use (count + 1) as your serial number on the new entry.

SQL
SELECT COUNT(Datecolumn) FROM Customers WHERE DateColumn='2013-03-05'


Hope this helps.

Regards
Jegan
 
Share this answer
 
Comments
Maciej Los 5-Mar-13 11:37am    
OP wants to get customer number of the day, but not to count no. of transactions.
Jegan Thiyagesan 5-Mar-13 12:23pm    
The number of customers entered into customer table per day is the count of number of transactions per day for that table.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900