Sorry , I think there is a misunderstanding ! Excuse me if I made you upset , I have a mysql manual but it`s not easy to find and fluence for me , I`ve learned many basic conceptions from SQL lessons in www.w3schools.com and mysql manual but sometimes when my problems get complicated I try to...
No , I don`t use mysql manual , I`ve just tried to find something from simple googling [wink]
Thanks for your peerless support , although my database will grow more but I hope to solve other future problems myself [hourglass]
Wonderful result :->
This is code :
SELECT leafCode
, colorsCode
, COALESCE(SUM(`INPUT`), 0) AS `INPUT`
, COALESCE(SUM(`OUTPUT`), 0) AS `OUTPUT`
, COALESCE(SUM(`INPUT`), 0) - COALESCE(SUM(`OUTPUT`), 0) AS `INVENTORY`
FROM ( SELECT rs_leaves.leafCode
...
Ok ,
I wrote this :
SELECT rs_leaves.leafCode,
rs_colors.colorsCode,
SUM(Distinct assign_details.assAmount) AS OUTPUT
FROM assign_details
INNER JOIN rs_leaves
ON assign_details.leafName = rs_leaves.leafID
INNER JOIN rs_colors
ON assign_details.leafColor = rs_colors.colorsID
GROUP BY...
No , it`s not possible . Every value in receipt_details.leafName exits in rs_leaves.leafID .
receipt_details table content confirm it :
+-----------+-------+----------+----------+-----------+-----------+------------+
| detailsID | recID | leafName | leafCode | leafColor | recAmount | recComment...
Thanks :)
This is first step :
SELECT rs_leaves.leafCode,
rs_colors.colorsCode,
SUM(Distinct receipt_details.recAmount) AS INPUT
FROM receipt_details
LEFT JOIN rs_leaves
ON receipt_details.leafName = rs_leaves.leafID
LEFT JOIN rs_colors
ON receipt_details.leafColor = rs_colors.colorsID...
Maybe I`m wrong , but from last post I found that I could write this query :
SELECT rs_leaves.leafCode,
rs_colors.colorsCode,
SUM(Distinct receipt_details.recAmount) AS INPUT,
SUM(Distinct assign_details.assAmount) AS OUTPUT,
SUM(Distinct receipt_details.recAmount) - SUM(Distinct...
Thanks Rudy for your reply ,
let`s assume there is a (warehouse), surely every warehouse
has some inputs and outputs . To calculate warehouse inventory
we use this formula : (inputs - outputs)
In my database inputs are in receipt_details table and outputs
are in assign_details table ; our...
Sry , I forgot to write this query :
COALESCE(Sum(Distinct receipt_details.recAmount), 0) - COALESCE(Sum(Distinct assign_details.assAmount), 0) As 'FWarehouse'
Because I want to migrate this SQL code to MySQL , I can`t use (Full Join) .
This is an example to describe more about this DB content and related problem :
rs_leaves table has data such :
leafID---> 1
leafCode---> A
leafName---> Wood
rs_colors table has data such :
colorsID---> 1...
Hello ,
There is 4 tables in my DB :
assign_details
receipt_details
rs_leaves
rs_colors
I should get all available data from "assign_details" and "receipt_details" tables , but now my query shows only common available data . For example when "assign_details" has an element that there is not in...
Hi ,
Can I mix my SQL code with some HTML tags ?
Let`s assume that this is main code :
Select projects.projectName,
projects.pictureName
Could I have something like this one instead of that :
Select projects.projectName,
<img src="./pics/projects.pictureName" />...
Thanks rudy , you are really a good teacher for teaching SQL power ; I used your hints and solved my many problems but still I`m confused with something else ! this is my final code :
Select t.projectName,
t.LeafCode, t.ColorsCode,
t.FirstWarehouse,
t.SecondWarehouse,
t.Sent,
t.OrderAmount...
Thanks r937 , now I found when should I use Case statement .
But could you please tell me how could I obtain this formula result with SQL :
(projects_details.OrderAmount) - (FirstWarehouse) + (FactoryInventory) = Remained
Should I unwrap (FirstWarehouse) and (FactoryInventory) to their original...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.