בעל דעת האט געשריבן:Add a temp table
SQL Server
די אחראים: זייער נייגעריג,אחראי,thefact
לייבעלע האט געשריבן:וויאזוי לייג איך צו צו דעם א קאלום postsoitem.totalprice ?
איך דארף א join צוווישן postsoitem.soitemid און soitem.id
שוין געמאכט. (געצאלט פאר א freelancer)
קאוד: וועל אויס אלע
inner join postsoitem on soitem.id = postsoitem.soitemid
-
- שר חמש מאות
- תגובות: 562
- זיך איינגעשריבן אום: פרייטאג מאי 17, 2013 4:12 pm
- לאקאציע: אין כולל
לייבעלע האט געשריבן:איך זוך לייוו הילף מיט קוועריס - פאר געלט.
צומאל ממש קליינעקייטן.
https://hackhands.com/
וואס דארף איך טון אריינצוברענגען די postso.extrefnumber (אין די צווייטע ליין)?
איך האב פרובירט מיט א join אין די ערשטע ליין, אבער כ'פארשטיי אז עפעס איז נישט ריכטיג.
איך האב פרובירט מיט א join אין די ערשטע ליין, אבער כ'פארשטיי אז עפעס איז נישט ריכטיג.
קאוד: וועל אויס אלע
SELECT postso.postdate as DateFulfilled, so.num as SONUM,
-- postso.extrefnumber as Invoice,
sum(case soitem.typeid when 70 then 0 when 30 then postsoitem.totalprice else(postsoitem.qty*soitem.unitprice) end) as TotalPrice,
bta.info as BlueTarpAuthNumber,
coalesce(case when gggparent.name = 'BlueTarp' then null else gggparent.name end, case when ggparent.name = 'BlueTarp' then null else ggparent.name end, case when gparent.name = 'BlueTarp' then null else gparent.name end, case when parent.name = 'BlueTarp' then null else parent.name end, customer.name) as "Acct Name",
iif(gggparent.name is not null, gggparent.name || ':','') || iif(ggparent.name is not null,ggparent.name || ':','') || iif(gparent.name is not null, gparent.name || ':' ,'') || iif(parent.name is not null,parent.name || ':','') || customer.name as CustomerCombined
FROM soitem
-- inner JOIN so ON postso.soid = so.id
INNER JOIN so ON soitem.soid = so.id
inner JOIN postsoitem ON soitem.id = postsoitem.soitemid
inner JOIN postso ON (postsoitem.postsoid = postso.id )
left join locationgroup on so.locationgroupid = locationgroup.id
LEFT JOIN taxrate on so.TAXRATEID = taxrate.id
INNER JOIN customer ON so.customerid = customer.id
left join product on soitem.productid= product.id
left join qbclass on soitem.qbclassid = qbclass.id
left join stateconst shiptostate on (shiptostate.id = so.shiptostateid)
left join stateconst billtostate on (billtostate.id = so.billtostateid)
left join uom on soitem.uomid = uom.id
left join part on product.partid = part.id
left join soitemtype on soitem.typeid = soitemtype.id
left join vendorparts vp on vp.partid = part.id and vp.defaultflag = 1
left join vendor on vendor.id = vp.vendorid
-- left join asaccount incomeaccount ON incomeaccount.id = COALESCE(product.INCOMEACCOUNTID, (select sysvalue from sysproperties where syskey like 'Acct ID salesRetail') )
-- left join asaccount cogsaccount ON cogsaccount.id = COALESCE(part.cogsACCOUNTID, (select sysvalue from sysproperties where syskey like 'Acct ID cogsAccount') )
-- left join asaccount assetaccount ON assetaccount.id = COALESCE(part.inventoryACCOUNTID, (select sysvalue from sysproperties where syskey like 'Acct ID inventoryAsset') )
left join customset bterms on bterms.customfieldid = 54 and bterms.recordid = so.id
left join customvarchar bta on bta.customfieldid = 53 and bta.recordid = so.id
left join customset ab on ab.customfieldid = 55 and ab.recordid = so.id
left join customer parent on parent.id = customer.parentid
left join customer gparent on gparent.id = parent.parentid
left join customer ggparent on ggparent.id = gparent.parentid
left join customer gggparent on gggparent.id = ggparent.parentid
where (postsoitem.id IS NOT NULL OR (soitem.typeid = 70 AND soitem.statusid = 50))
and cast(postso.postdate as date) between ?
and ? +.9999
group by
--postsoitem.extrefnumber,
so.num, postso.postdate,
bta.info,
coalesce(case when gggparent.name = 'BlueTarp' then null else gggparent.name end, case when ggparent.name = 'BlueTarp' then null else ggparent.name end, case when gparent.name = 'BlueTarp' then null else gparent.name end, case when parent.name = 'BlueTarp' then null else parent.name end, customer.name),
iif(gggparent.name is not null, gggparent.name || ':','') || iif(ggparent.name is not null,ggparent.name || ':','') || iif(gparent.name is not null, gparent.name || ':' ,'') || iif(parent.name is not null,parent.name || ':','') || customer.name
order by postso.postdate
- בחורהזעצער
- שר חמש מאות
- תגובות: 961
- זיך איינגעשריבן אום: זונטאג יאנואר 16, 2011 9:54 am
לייבעלע האט געשריבן:וואס דארף איך טון אריינצוברענגען די postso.extrefnumber (אין די צווייטע ליין)?
איך האב פרובירט מיט א join אין די ערשטע ליין, אבער כ'פארשטיי אז עפעס איז נישט ריכטיג.קאוד: וועל אויס אלע
SELECT postso.postdate as DateFulfilled, so.num as SONUM,
-- postso.extrefnumber as Invoice,
sum(case soitem.typeid when 70 then 0 when 30 then postsoitem.totalprice else(postsoitem.qty*soitem.unitprice) end) as TotalPrice,
bta.info as BlueTarpAuthNumber,
coalesce(case when gggparent.name = 'BlueTarp' then null else gggparent.name end, case when ggparent.name = 'BlueTarp' then null else ggparent.name end, case when gparent.name = 'BlueTarp' then null else gparent.name end, case when parent.name = 'BlueTarp' then null else parent.name end, customer.name) as "Acct Name",
iif(gggparent.name is not null, gggparent.name || ':','') || iif(ggparent.name is not null,ggparent.name || ':','') || iif(gparent.name is not null, gparent.name || ':' ,'') || iif(parent.name is not null,parent.name || ':','') || customer.name as CustomerCombined
FROM soitem
-- inner JOIN so ON postso.soid = so.id
INNER JOIN so ON soitem.soid = so.id
inner JOIN postsoitem ON soitem.id = postsoitem.soitemid
inner JOIN postso ON (postsoitem.postsoid = postso.id )
left join locationgroup on so.locationgroupid = locationgroup.id
LEFT JOIN taxrate on so.TAXRATEID = taxrate.id
INNER JOIN customer ON so.customerid = customer.id
left join product on soitem.productid= product.id
left join qbclass on soitem.qbclassid = qbclass.id
left join stateconst shiptostate on (shiptostate.id = so.shiptostateid)
left join stateconst billtostate on (billtostate.id = so.billtostateid)
left join uom on soitem.uomid = uom.id
left join part on product.partid = part.id
left join soitemtype on soitem.typeid = soitemtype.id
left join vendorparts vp on vp.partid = part.id and vp.defaultflag = 1
left join vendor on vendor.id = vp.vendorid
-- left join asaccount incomeaccount ON incomeaccount.id = COALESCE(product.INCOMEACCOUNTID, (select sysvalue from sysproperties where syskey like 'Acct ID salesRetail') )
-- left join asaccount cogsaccount ON cogsaccount.id = COALESCE(part.cogsACCOUNTID, (select sysvalue from sysproperties where syskey like 'Acct ID cogsAccount') )
-- left join asaccount assetaccount ON assetaccount.id = COALESCE(part.inventoryACCOUNTID, (select sysvalue from sysproperties where syskey like 'Acct ID inventoryAsset') )
left join customset bterms on bterms.customfieldid = 54 and bterms.recordid = so.id
left join customvarchar bta on bta.customfieldid = 53 and bta.recordid = so.id
left join customset ab on ab.customfieldid = 55 and ab.recordid = so.id
left join customer parent on parent.id = customer.parentid
left join customer gparent on gparent.id = parent.parentid
left join customer ggparent on ggparent.id = gparent.parentid
left join customer gggparent on gggparent.id = ggparent.parentid
where (postsoitem.id IS NOT NULL OR (soitem.typeid = 70 AND soitem.statusid = 50))
and cast(postso.postdate as date) between ?
and ? +.9999
group by
--postsoitem.extrefnumber,
so.num, postso.postdate,
bta.info,
coalesce(case when gggparent.name = 'BlueTarp' then null else gggparent.name end, case when ggparent.name = 'BlueTarp' then null else ggparent.name end, case when gparent.name = 'BlueTarp' then null else gparent.name end, case when parent.name = 'BlueTarp' then null else parent.name end, customer.name),
iif(gggparent.name is not null, gggparent.name || ':','') || iif(ggparent.name is not null,ggparent.name || ':','') || iif(gparent.name is not null, gparent.name || ':' ,'') || iif(parent.name is not null,parent.name || ':','') || customer.name
order by postso.postdate
באקומסט אן ערראר?
- בחורהזעצער
- שר חמש מאות
- תגובות: 961
- זיך איינגעשריבן אום: זונטאג יאנואר 16, 2011 9:54 am
ס'איז קלאר יא דא:
קאוד: וועל אויס אלע
SELECT POSTSO.ID, POSTSO.SOID, POSTSO.POSTDATE, POSTSO.STATUSID, POSTSO.EXTTXNID, POSTSO.EXTTXNHASH, POSTSO.EXTTXNNUMBER, POSTSO.EXTREFNUMBER, POSTSO.DATEPOSTED, POSTSO.DATECREATED, POSTSO.DATELASTMODIFIED, POSTSO.JOURNALTXNID, POSTSO.JOURNALPOSTED
FROM POSTSO POSTSO
WHERE (POSTSO.DATECREATED>'2018-05-25')
- איד'ל מיטן פידל
- שר חמש מאות
- תגובות: 874
- זיך איינגעשריבן אום: דאנערשטאג מאי 01, 2014 10:14 am
- לאקאציע: צווישן די סטרונעס
לייבעלע האט געשריבן:ס'איז קלאר יא דא:קאוד: וועל אויס אלע
SELECT POSTSO.ID, POSTSO.SOID, POSTSO.POSTDATE, POSTSO.STATUSID, POSTSO.EXTTXNID, POSTSO.EXTTXNHASH, POSTSO.EXTTXNNUMBER, POSTSO.EXTREFNUMBER, POSTSO.DATEPOSTED, POSTSO.DATECREATED, POSTSO.DATELASTMODIFIED, POSTSO.JOURNALTXNID, POSTSO.JOURNALPOSTED
FROM POSTSO POSTSO
WHERE (POSTSO.DATECREATED>'2018-05-25')
this query works?
- איד'ל מיטן פידל
- שר חמש מאות
- תגובות: 874
- זיך איינגעשריבן אום: דאנערשטאג מאי 01, 2014 10:14 am
- לאקאציע: צווישן די סטרונעס
so this query doesn't work?
קאוד: וועל אויס אלע
SELECT postso.postdate as DateFulfilled, so.num as SONUM,
-- postso.extrefnumber as Invoice,
sum(case soitem.typeid when 70 then 0 when 30 then postsoitem.totalprice else(postsoitem.qty*soitem.unitprice) end) as TotalPrice,
bta.info as BlueTarpAuthNumber,
coalesce(case when gggparent.name = 'BlueTarp' then null else gggparent.name end, case when ggparent.name = 'BlueTarp' then null else ggparent.name end, case when gparent.name = 'BlueTarp' then null else gparent.name end, case when parent.name = 'BlueTarp' then null else parent.name end, customer.name) as "Acct Name",
iif(gggparent.name is not null, gggparent.name || ':','') || iif(ggparent.name is not null,ggparent.name || ':','') || iif(gparent.name is not null, gparent.name || ':' ,'') || iif(parent.name is not null,parent.name || ':','') || customer.name as CustomerCombined
FROM soitem
-- inner JOIN so ON postso.soid = so.id
INNER JOIN so ON soitem.soid = so.id
inner JOIN postsoitem ON soitem.id = postsoitem.soitemid
inner JOIN postso ON (postsoitem.postsoid = postso.id )
left join locationgroup on so.locationgroupid = locationgroup.id
LEFT JOIN taxrate on so.TAXRATEID = taxrate.id
INNER JOIN customer ON so.customerid = customer.id
left join product on soitem.productid= product.id
left join qbclass on soitem.qbclassid = qbclass.id
left join stateconst shiptostate on (shiptostate.id = so.shiptostateid)
left join stateconst billtostate on (billtostate.id = so.billtostateid)
left join uom on soitem.uomid = uom.id
left join part on product.partid = part.id
left join soitemtype on soitem.typeid = soitemtype.id
left join vendorparts vp on vp.partid = part.id and vp.defaultflag = 1
left join vendor on vendor.id = vp.vendorid
-- left join asaccount incomeaccount ON incomeaccount.id = COALESCE(product.INCOMEACCOUNTID, (select sysvalue from sysproperties where syskey like 'Acct ID salesRetail') )
-- left join asaccount cogsaccount ON cogsaccount.id = COALESCE(part.cogsACCOUNTID, (select sysvalue from sysproperties where syskey like 'Acct ID cogsAccount') )
-- left join asaccount assetaccount ON assetaccount.id = COALESCE(part.inventoryACCOUNTID, (select sysvalue from sysproperties where syskey like 'Acct ID inventoryAsset') )
left join customset bterms on bterms.customfieldid = 54 and bterms.recordid = so.id
left join customvarchar bta on bta.customfieldid = 53 and bta.recordid = so.id
left join customset ab on ab.customfieldid = 55 and ab.recordid = so.id
left join customer parent on parent.id = customer.parentid
left join customer gparent on gparent.id = parent.parentid
left join customer ggparent on ggparent.id = gparent.parentid
left join customer gggparent on gggparent.id = ggparent.parentid
where (postsoitem.id IS NOT NULL OR (soitem.typeid = 70 AND soitem.statusid = 50))
and cast(postso.postdate as date) between ?
and ? +.9999
group by
--postsoitem.extrefnumber,
so.num, postso.postdate,
bta.info,
coalesce(case when gggparent.name = 'BlueTarp' then null else gggparent.name end, case when ggparent.name = 'BlueTarp' then null else ggparent.name end, case when gparent.name = 'BlueTarp' then null else gparent.name end, case when parent.name = 'BlueTarp' then null else parent.name end, customer.name),
iif(gggparent.name is not null, gggparent.name || ':','') || iif(ggparent.name is not null,ggparent.name || ':','') || iif(gparent.name is not null, gparent.name || ':' ,'') || iif(parent.name is not null,parent.name || ':','') || customer.name
order by postso.postdate
- איד'ל מיטן פידל
- שר חמש מאות
- תגובות: 874
- זיך איינגעשריבן אום: דאנערשטאג מאי 01, 2014 10:14 am
- לאקאציע: צווישן די סטרונעס
לייבעלע האט געשריבן:ריכטיג. ווען איך פרוביר די join (אראפנעמענדיג די -- פארשטייצעך) באקום איך די עראר ווי אויבן
of course, because you're trying to join on a column of a table thats not yet in your query
the from clause works in the order you're writing it, so table 'postso' is not yet in your from clause
יעצט געפאוסט אויף upwork.com א נייע קווערי וואס איך דארף.
אויב גלייבט איינער אז ער קען עס מאכן, זאל מיר לאזן וויסן.
https://www.upwork.com/jobs/~0121a8e09c4c68b22e
אויב גלייבט איינער אז ער קען עס מאכן, זאל מיר לאזן וויסן.
https://www.upwork.com/jobs/~0121a8e09c4c68b22e
- דוד משה
- שר האלף
- תגובות: 1668
- זיך איינגעשריבן אום: זונטאג דעצעמבער 01, 2013 4:04 pm
- לאקאציע: געשטראנדעט צווישן מעיזשאר און מיינאר
לייבעלע האט געשריבן:יעצט א נייע עראר:
די עראר זאגט אז עס איז דא אינעם קווערי 2 קאלום'ס מיט די זעלבע נאמען און ער ווערט צומישט צווישן די צוויי, דו דארפסט שרייבן טעיבל.קאלום
בכל אופן וואלט איך דיר געראטן צו נעמען איינער וואס זאל דיר דאס אויפסעטן ווי א מענטש און דו זאלסט דיך נישט דארפן מוטשענען מיט שרייבן קוועריס און טראבלשוטן עראר'ס.
הצלחה
> הער אויף ארויפצולייגן ווערטער אויף ניגונים! אויב ווילסטו א ניגון אויף די ווערטער קאמפאזיר א ניגון דערויף <
ליידיג
~ דער וואס איז דיין חבר ווילאנג דו האסט די זעלבע מיינונג ווי אים, איז קיין חבר ~
וויאזוי ארויפצולייגן א לינקעראר שוין פאראכטן ב"ה.
איז דא א וועג צו מאכן פון דעם א נייע קאלום נאמען דורך א join כדאי איך זאל עס גרינג קענען איבערנוצן אן דארפן נאכאמאל איבערשרייבן די גאנצע iif אינעם זעלבן קווערי?
(אפשר דורך מאכן דערפון א newtable.id ?)
איז דא א וועג צו מאכן פון דעם א נייע קאלום נאמען דורך א join כדאי איך זאל עס גרינג קענען איבערנוצן אן דארפן נאכאמאל איבערשרייבן די גאנצע iif אינעם זעלבן קווערי?
(אפשר דורך מאכן דערפון א newtable.id ?)
קאוד: וועל אויס אלע
iif(gggparent.name is not null, gggparent.name || ':','') || iif(ggparent.name is not null,ggparent.name || ':','') || iif(gparent.name is not null, gparent.name || ':' ,'') || iif(parent.name is not null,parent.name || ':','') || customer.name as "Customer Path"
- איד'ל מיטן פידל
- שר חמש מאות
- תגובות: 874
- זיך איינגעשריבן אום: דאנערשטאג מאי 01, 2014 10:14 am
- לאקאציע: צווישן די סטרונעס
לייבעלע האט געשריבן:עראר שוין פאראכטן ב"ה.
איז דא א וועג צו מאכן פון דעם א נייע קאלום נאמען דורך א join כדאי איך זאל עס גרינג קענען איבערנוצן אן דארפן נאכאמאל איבערשרייבן די גאנצע iif אינעם זעלבן קווערי?
(אפשר דורך מאכן דערפון א newtable.id ?)קאוד: וועל אויס אלע
iif(gggparent.name is not null, gggparent.name || ':','') || iif(ggparent.name is not null,ggparent.name || ':','') || iif(gparent.name is not null, gparent.name || ':' ,'') || iif(parent.name is not null,parent.name || ':','') || customer.name as "Customer Path"
use a sub query
see code - try it
קאוד: וועל אויס אלע
select main.[Customer Path] from
(select iif(gggparent.name is not null, gggparent.name || ':','') || iif(ggparent.name is not null,ggparent.name || ':','') || iif(gparent.name is not null, gparent.name || ':' ,'') || iif(parent.name is not null,parent.name || ':','') || customer.name as "Customer Path"
from blabla)main
- איד'ל מיטן פידל
- שר חמש מאות
- תגובות: 874
- זיך איינגעשריבן אום: דאנערשטאג מאי 01, 2014 10:14 am
- לאקאציע: צווישן די סטרונעס
קאוד: וועל אויס אלע
SELECT POSTSO.EXTREFNUMBER as Invoice, SO.NUM as "SO Num", replace(replace(POSTORDERSTATUS.NAME,'For Invoice','Pending'),'Invoice','Posted') as Status, sum(POSTSOITEM.TOTALPRICE) as Amount, cast(postso.datecreated as date) as Fulfilled,
case when iif(gggparent.name is not null, gggparent.name || ':','') || iif(ggparent.name is not null,ggparent.name || ':','') || iif(gparent.name is not null, gparent.name || ':' ,'') || iif(parent.name is not null,parent.name || ':','') || customer.name like 'BlueTarp%' then 'BlueTarp' end as BlueTarp,
bta.info as BTAuth,
coalesce(case when gggparent.name = 'BlueTarp' then null else gggparent.name end, case when ggparent.name = 'BlueTarp' then null else ggparent.name end, case when gparent.name = 'BlueTarp' then null else gparent.name end, case when parent.name = 'BlueTarp' then null else parent.name end, customer.name) as "Account Name",
iif(gggparent.name is not null, gggparent.name || ':','') || iif(ggparent.name is not null,ggparent.name || ':','') || iif(gparent.name is not null, gparent.name || ':' ,'') || iif(parent.name is not null,parent.name || ':','') || customer.name as "Customer Path"
FROM POSTORDERSTATUS POSTORDERSTATUS, POSTSO POSTSO, POSTSOITEM POSTSOITEM, SO SO
left join customvarchar bta on bta.customfieldid = 53 and bta.recordid = so.id
INNER JOIN customer ON so.customerid = customer.id
left join customer parent on parent.id = customer.parentid
left join customer gparent on gparent.id = parent.parentid
left join customer ggparent on ggparent.id = gparent.parentid
left join customer gggparent on gggparent.id = ggparent.parentid
WHERE SO.ID = POSTSO.SOID AND POSTSO.STATUSID = POSTORDERSTATUS.ID AND POSTSOITEM.POSTSOID = POSTSO.ID
and (cast(postso.dateposted as date) between ? and ? +.9999 OR postso.dateposted is null)
Group By POSTSO.EXTREFNUMBER, SO.NUM, POSTORDERSTATUS.NAME, postso.datecreated,
coalesce(case when gggparent.name = 'BlueTarp' then null else gggparent.name end, case when ggparent.name = 'BlueTarp' then null else ggparent.name end, case when gparent.name = 'BlueTarp' then null else gparent.name end, case when parent.name = 'BlueTarp' then null else parent.name end, customer.name),
bta.info,
iif(gggparent.name is not null, gggparent.name || ':','') || iif(ggparent.name is not null,ggparent.name || ':','') || iif(gparent.name is not null, gparent.name || ':' ,'') || iif(parent.name is not null,parent.name || ':','') || customer.name
Order By POSTORDERSTATUS.NAME