August 25, 2015 at 5:56 pm
SELECT
part.num, woitem.qtytarget AS woitemqty,
(SELECT LIST(wo.num, ',')
FROM wo INNER JOIN moitem ON wo.moitemid = moitem.id
WHERE moitem.moid = mo.id) AS wonums, mo."USERID" AS mo_USERID
FROM mo
INNER JOIN moitem ON mo.id = moitem.moid
LEFT JOIN wo ON moitem.id = wo.moitemid
LEFT JOIN woitem ON wo.id = woitem.woid AND woitem.typeid = 10
LEFT JOIN (Select sum(woitem.qtytarget) as labor, woitem.woid, uom.code as uom
from woitem
JOIN part on woitem.partid = part.id and part.typeid = 21
JOIN uom on woitem.uomid = uom.id
group by 2,3) as labor on wo.id = labor.woid
LEFT JOIN part ON woitem.partid = part.id
where woitem.qtytarget/wo.qtytarget IS NOT NULL
SELECT
MO."USERID" AS MO_USERID,
SYSUSER."USERNAME" AS SYSUSER_USERNAME
FROM
"SYSUSER" SYSUSER INNER JOIN "MO" MO ON SYSUSER."ID" = MO."USERID"
August 26, 2015 at 7:18 am
chindilog (8/25/2015)
SELECTpart.num, woitem.qtytarget AS woitemqty,
(SELECT LIST(wo.num, ',')
FROM wo INNER JOIN moitem ON wo.moitemid = moitem.id
WHERE moitem.moid = mo.id) AS wonums, mo."USERID" AS mo_USERID
FROM mo
INNER JOIN moitem ON mo.id = moitem.moid
LEFT JOIN wo ON moitem.id = wo.moitemid
LEFT JOIN woitem ON wo.id = woitem.woid AND woitem.typeid = 10
LEFT JOIN (Select sum(woitem.qtytarget) as labor, woitem.woid, uom.code as uom
from woitem
JOIN part on woitem.partid = part.id and part.typeid = 21
JOIN uom on woitem.uomid = uom.id
group by 2,3) as labor on wo.id = labor.woid
LEFT JOIN part ON woitem.partid = part.id
where woitem.qtytarget/wo.qtytarget IS NOT NULL
SELECT
MO."USERID" AS MO_USERID,
SYSUSER."USERNAME" AS SYSUSER_USERNAME
FROM
"SYSUSER" SYSUSER INNER JOIN "MO" MO ON SYSUSER."ID" = MO."USERID"
Is there a question here?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
August 26, 2015 at 7:20 am
chindilog (8/25/2015)
(SELECT LIST(wo.num, ',')
can you please explain what "SELECT LIST" does....are you using MS SQL?
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
August 26, 2015 at 7:23 am
Going off the post about this query at http://www.sqlservercentral.com/Forums/Topic1714385-391-1.aspx#bm1714502, this is something called Firebird SQL.
August 26, 2015 at 7:41 am
Ed Wagner (8/26/2015)
Going off the post about this query at http://www.sqlservercentral.com/Forums/Topic1714385-391-1.aspx#bm1714502, this is something called Firebird SQL.
Interesting. As much I would be willing to help I think I will walk away from this. I know nothing about Firebird and anything I might suggest is highly likely to be incorrect for a database engine I have never heard of before.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
August 26, 2015 at 7:56 am
Sean Lange (8/26/2015)
Ed Wagner (8/26/2015)
Going off the post about this query at http://www.sqlservercentral.com/Forums/Topic1714385-391-1.aspx#bm1714502, this is something called Firebird SQL.Interesting. As much I would be willing to help I think I will walk away from this. I know nothing about Firebird and anything I might suggest is highly likely to be incorrect for a database engine I have never heard of before.
I'm in the same boat. I had never heard of it until this week. A simple SUM and GROUP BY didn't work, so I'm at a complete loss as to what it is. Then again, I didn't do any research on Firebird. The only Firebird I know of is a car. 😛
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply