question

abdol avatar image
abdol asked

Summary of Transaction

Table Master ------------- BillNo nvarchar no 100 BillDate datetime no 8 Data in table Master ----------------------- A0300000160 2010-10-06 19:06:16.000 A0300000161 2010-10-06 19:06:29.000 A0300000162 2010-10-06 19:07:03.000 A0300000163 2010-10-06 19:07:34.000 A0300000164 2010-10-06 19:09:24.000 Table Child ------------------ BillNo nvarchar no 40 ProductID nvarchar no 40 ProductRate real no 4 24 Qty real no 4 24 ccode nvarchar no 8 Data in table Child -------------------- A0300000161 TK009 22.0 2.0 TK A0300000162 CC001 44.09 1.0 CC A0300000162 TK009 22.0 1.0 TK A0300000163 CP008 342.60 0.25 CP A0300000164 TK009 22.0 2.0 TK A0300000165 TK009 22.0 1.0 TK Table Cateogry_Master ---------------------- CCode nvarchar no 40 CName nvarchar no 200 Date in Category_Master ---------------------- FC Coffee CP Coffee Powder SN Snacks ES Hot Coffee CC Cold Coffee MR Merchandise TK Takeaway **Expected Result** CName Total_Bills ---------------------- Takeaway 3 Coffe Powder 1 Mixed 1 Expected Result : Summary of transaction, if each bill has mixed cateogy of products then it will be counted as Mixed otherwise can calculate based on category code **This is my code but am not getting expecting result.** select count(*) as count, c.ccode from tblbilldetails as c, tblbill b where b.billno=c.billno and b.billdate>='2010-10-11 11:43:48.000' and b.billdate<='2010-10-11 12:43:48.000' group by c.ccode
count
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kev Riley avatar image Kev Riley ♦♦ commented ·
What have you tried so far? Any query, no matter how simple, will show us how far you have got. Otherwise it just feels like we are doing all the work for you. This feels like a homework question, and you'll learn more if you try....
0 Likes 0 ·
abdol avatar image abdol commented ·
I have pasted the text from this answer into the original question, and then converted it to a comment to the question. //Magnus Ahlkvist
0 Likes 0 ·

1 Answer

·
Blackhawk-17 avatar image
Blackhawk-17 answered
In your code you are asking for times that are both greater and less than a range... a time can only be one or the other: where b.billno=c.billno and b.billdate>='2010-10-11 11:43:48.000' and b.billdate
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.