TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
multi 4u
NA
19
1.9k
WHILE LOOP IN SQL SERVER
Mar 20 2017 6:25 AM
here is my sql query stored procedure given below.
i want some change in my query that if the lapucurrentbal is not 0.00 than it will fetch the last record so for that i have to used while loop here that if it contains 0.00 than it go for top1 and if in top 1 record lapucurrentbal is also 0.00 than again it go for top2 and thus it will continue until and unless lapucurrentbal is not 0.00
create procedure sp_LapuOpeningBal
(
@lapumobileno varchar(50)
)
as
begin
select top 1 LapuCurrentBal as Opening,lapumobileno,RechargeDate from recharge where RechargeDate
< dateadd(day,datediff(day,0,GETDATE()),0)
and RechargeDate >dateadd(day,datediff(day,1,GETDATE()),0)
and lapumobileno=@lapumobileno group by LapuCurrentBal,LapuMobileNo,RechargeDate order by RechargeDate desc
end
Reply
Answers (
2
)
from using table between two dates get the in between dates
How to select OT hours from below table?