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
Rocky Rocky
NA
317
151.7k
How to work out on these query?
Jan 17 2014 12:25 AM
Forums
»
.NET
»
SQL Server
»
How to work out on these query?
Posted Date:
16 Jan 2014
Posted By::
Rocky
Member Level:
Silver
Member Rank:
1376
Points
: 5
Responses:
0
my table looks like
invoice_no model_ref item_type item_no invoice_qty
tn/0002/13-14 - I 5000350 5
" - K 6000350 10
" 6000350 X 5000242 15
" 6000350 X 5000470 2
MB/0006/13-14 - K 6000370 10
" 6000370 X 5000460 10
" 6000370 X 5000480 1
like i ve lakh of recors in my table
table struct:
+++++++++
create table invoice_item
(
invoice_no varchar(20),
model_ref int,
item_type char(10),
item_no varchar(20),
invoice_qty int
)
insert into invoice_item(invoice_no,model_ref,item_type,item_no,invoice_qty)
values ('tn/0002/13-14','-','I','5000350','5')
' ('tn/0002/13-14','-','K','6000350','10')
' ('tn/0002/13-14','6000350','X','5000242','15')
My EXPECTING O/P:
invoice_no item_no Sales Free
tn/0002/13-14 5000350 5 0
tn/0002/13-14 5000242 10 5
tn/0002/13-14 5000470 0 2
MB/0006/13-14 5000460 10 0
MB/0006/13-14 5000480 0 1
here Item_types "I" directly billed item so it ll reflect free "0" always.
but when we billed along with "K"(kit) highest value takes billed remaining as free(I.E 6000350 kit was billed on tn/0002/13-14 with 10 QTY
actually it contains 5000242 = 15 QTY & 5000470 = 2 QTY
highest values (5000242=15) is less from kit billed. shows like line number 2,3 from my expecting O/P table)
how to do that?
Reply
Answers (
0
)
Change Tracking in SQL Server
Convert in sql server