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
nijisha k c
NA
27
2.1k
How to retrieve boolean column based on drop down list value
May 22 2015 12:07 AM
i have a form in which i want to show the data based on user's selection..in this form there is a drop down list with items
'posted','drafted','all'. when user select posted i want to retrieve data by condition Voucher status=true, and when user select drafted i want to retrieve data by condition Voucher status=false. and when user select all i want to retrieve data by condition Voucher status=true or false or null.ie in third display all.(dont want to consider voucher status)
Pls help me to solve this query..
my complete query is here..
SELECT VoucherTypes.types, VoucherHead.VoucherNo, VoucherHead.VoucherDate, SUM(VoucherDetail.Debit) AS debit, SUM(VoucherDetail.Credit) AS credit, VoucherHead.VoucherStatus
FROM VoucherHead INNER JOIN VoucherTypes ON VoucherHead.VoucherType = VoucherTypes.vtypeid INNER JOIN
VoucherDetail ON VoucherHead.VoucherID = VoucherDetail.VoucherID
WHERE (VoucherHead.VoucherDate >= @fromdate) AND (VoucherHead.VoucherDate <= @todate) AND (VoucherTypes.types = @vtype or @vtype='0') AND (VoucherHead.VoucherStatus = @st) AND (VoucherHead.Branchno = @branchid)
GROUP BY VoucherTypes.types, VoucherHead.VoucherNo, VoucherHead.VoucherDate, VoucherHead.VoucherStatus
here
if (status == 1)
st = true;
if (status == 2)
st = false;
where status=drp.selectedindex;
but this works only selecting 'posted' or 'drafted'.. it also be worked when selecting 'all'...
is this can de done using 'case'..i dont know
Reply
Answers (
1
)
Why are the reasons that WE use nested queries IN SQL server
How can I solve the bank's E/R queries in SQL SERVER?