Click here to Skip to main content
15,891,253 members

How to display all the records from left table which is joined to another table

Sunil Bansode asked:

Open original thread
Respected sir,
I m developing windows application using vb.net with MS-Access as backend.
I want to generate sales report by selecting perticuler month
for that i m trying to develope sql query...

table : Stock
----------------------------------------------
id item      size unit  MRP
----------------------------------------------
1  abc        500 gm    120  
2  xyz        500 gm    180
3  pqr        150 gm     60
4  lmn         50 gm     20
5  pqr          1 kg    500
----------------------------------------------    

table : Sale
---------------------------------------------
sr   Billno  bill_Date    itemID  Qnty   Total
---------------------------------------------
1     123    14/11/2013    1      2      240
2     123    14/11/2013    3      2      120
3     123    14/11/2013    4      3       60
4     124    20/02/2013    5      2     1000
5     124    20/02/2013    3      5      300  
---------------------------------------------
 
I want to show required month's sales report like below
for example month=11

sr  ItemName size unit  MRP  totalQnty TotalAmt
--------------------------------------------------
1.    abc     500 gm    120     1         240
2.    xyz     500 gm    180     0           0
3.    pqr     150 gm     60     7         420
4.    lmn      50 gm     20     3          60
5.    pqr       1 kg    500     0           0
---------------------------------------------------

here i want to dislpay all the items present in stock and beside that how many items are sold in this perticular month,if that item is not sold in given month then it should be blank as i shown in above example sr. 5 pqr was sold in month no=2 and not in 11 so its showing zero..likewise...

what would be SQL query for this..

Please help me,
Thank you,..
Tags: Visual Basic, SQL

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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