Hi , this problem is related to SQL not SQLServer but I hope somebody guide me ;
This is part of my sample query :
Select projects.projectName,
Sum(sent_receive_tbl.ReceivedNum) - Sum(sent_receive_tbl.SentNum) As 'FirstWarehouse',
...
From
....
Group By projects.projectName,
....
Having sent_receive_tbl.StationID = '7'
This query shows me (FirstWarehose) for those StationID that are equal (7) . Now I want to have additional column in above SQL code like this :
Sum(sent_receive_tbl.ReceivedNum) - Sum(sent_receive_tbl.SentNum) As 'SecondWarehouse',
But now I want to see (SecondWarehouse) for those StationID that are equal (8) .
How can I do it ?
Another issue is calculating a value with using other (Select statements) ;
let`s assume that we have this sample query :
Select projects.projectName,
Sum(sent_receive_tbl.ReceivedNum) - Sum(sent_receive_tbl.SentNum) As 'FirstWarehouse',
Sum(Distinct receipt_details.rAmount) - Sum(Distinct
assignment_details.Amount) As 'FactoryInventory',
projects_details.OrderAmount
From
....
Group By projects.projectName,
....
Having sent_receive_tbl.StationID = '7'
How can I write this formula with SQL :
(projects_details.OrderAmount) - (FirstWarehouse) + (FactoryInventory) = Remained
In fact I want to have a column in my report that shows me (Remained Value) .
How can I do it ?
This is part of my sample query :
Select projects.projectName,
Sum(sent_receive_tbl.ReceivedNum) - Sum(sent_receive_tbl.SentNum) As 'FirstWarehouse',
...
From
....
Group By projects.projectName,
....
Having sent_receive_tbl.StationID = '7'
This query shows me (FirstWarehose) for those StationID that are equal (7) . Now I want to have additional column in above SQL code like this :
Sum(sent_receive_tbl.ReceivedNum) - Sum(sent_receive_tbl.SentNum) As 'SecondWarehouse',
But now I want to see (SecondWarehouse) for those StationID that are equal (8) .
How can I do it ?
Another issue is calculating a value with using other (Select statements) ;
let`s assume that we have this sample query :
Select projects.projectName,
Sum(sent_receive_tbl.ReceivedNum) - Sum(sent_receive_tbl.SentNum) As 'FirstWarehouse',
Sum(Distinct receipt_details.rAmount) - Sum(Distinct
assignment_details.Amount) As 'FactoryInventory',
projects_details.OrderAmount
From
....
Group By projects.projectName,
....
Having sent_receive_tbl.StationID = '7'
How can I write this formula with SQL :
(projects_details.OrderAmount) - (FirstWarehouse) + (FactoryInventory) = Remained
In fact I want to have a column in my report that shows me (Remained Value) .
How can I do it ?