Skip to content
Advertisement

Syntax sql server [closed]

I have a problem in syntax sql, i have 3 tables like this

Table : Stock

Table : Purchase

Table : Sales

I want if i query for date >= ’07/01/2019′ and date <=’07/07/2019′ the stock will be

i want to know the beginstock in before month and after month, please help me how the query in sql. Sorry i’m the newbie. Thank’s for helping

Advertisement

Answer

Assuming all stock codes are present in the Stock table, you can use CROSS APPLY like this:

Alternatively, you can use LEFT JOIN with GROUP BY in the derived tables, like this:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement