OR
SELECT
ERP.ERP_Line_Num
,ERP.Item
,A.[Count]
FROM
ERP
INNER JOIN
(SELECT
ERP_Line_Num
,COUNT(ERP_Line_Num) AS [Count]
FROM ERP
GROUP BY ERP_Line_Num) AS A
ON ERP.ERP_Line_Num = A.ERP_Line_Num
sabin MCP
Hi,
;with ERP (ERP_Line_Num, Item)
AS
(select '001','0083104' union all
select '001','0210901' union all
select '002','0049703' union all
select '003','0049806')
SELECT ERP_Line_Num
, Item
,COUNT(ERP_Line_Num) OVER(PARTITION BY ERP_Line_Num ORDER BY ERP_Line_Num ASC) AS [Count]...
;with Users (UserID,UserName,GroupID)
AS
(SELECT 1 ,'Joe',3 UNION ALL
SELECT 2 ,'Dave',5 UNION ALL
SELECT 3 ,'Geoff', 2 UNION ALL
SELECT 4 ,'Gordon', 1 UNION ALL
SELECT 5 ,'Jane', 4 )
,Groups (GroupID,GroupName)
AS
(SELECT 1,'Group1' UNION ALL
SELECT 2,'Group2' UNION ALL
SELECT...
Hi,
;with aCTE
AS
( select 'test1' modelno,'scratch' defect_type,10 qty union all
select 'test2','dent', 5 union all
select 'test3','deform', 20 )
select *
from aCTE
pivot(SUM(QTY) FOR modelNo in ([test1],[test2],[test3])) PV
Order by defect_type desc
and the output:
defect_type...
run this:
select t0.SupplierName,t0.Dscription
from dbo.Paul_MOBA_History_SB as t0
WHERE t0.SupplierName like '%Berkana%'
GROUP BY t0.SupplierName,t0.Dscription
and this:
select t0.SupplierName,t0.Dscription
from dbo.Paul_MOBA_History_SB as t0
where t0.FirstDate >= @FromDate and...
It's possible that , in view/table dbo.Paul_MOBA_History_SB, the value for FirstDate is null?
- add another column to those select :
select ..., 1 as express
union all
select ....,2
to be able to find from where is coming those rows (first select or second select)
depending of what result...
declare @FromDate as DATE
,@ToDate as DATE
SET @FromDate=CONVERT(date, DATEADD(d,-7,getdate()))
SET @ToDate=CONVERT(date, getdate())
;with Farm
AS
(select 'Berkana Park' as SupplierName, 'Blood' as Dscription ,0 as EggPercent ,'2014-03-15' as FirstDate union all
select 'Berkana...
Hi,
You can use ISNULL function ; isnull(expression,1) as EggPercent
SELECT LEFT(t0.SupplierName,LEN(t0.SupplierName)-2) As Farm, t0.Dscription
, ISNULL((case when t0.Dscription = 'Oversize' then sum(t0.Eggs) / sum(t0.TotalEggs/2) else sum(t0.Eggs) / sum(t0.TotalEggs) end)*100,1) As...
select varcharField as xmlField
FROM bCTE
all the rows must look like this
<Address>
<ad>something</ad>
</Address>
ignor for now,
select
t.u.value('ad[1]','varchar(500)') as [add1]
,t.u.value('ad[2]','varchar(500)') as [add2]
,t.u.value('ad[3]','varchar(500)') as [add3]...
yes , because , now , this is not a xml field
it;s only for a look to see how is the final result before parse it to xml
select varcharField as xmlField
FROM bCTE
Ce-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mut
sabin
with welcome
SELECT
AgentID
,Time
,EndDate
,Date
,CASE WHEN [Condition]=2 THEN 'FULL'
WHEN [Condition]=1 THEN 'PARTIAL'
ELSE 'No' END as [Condition]
FROM
(
SELECT *
, row_number() Over(Partition by Time Order by Condition desc) as rn
FROM(
SELECT atdAgentID AgentID,
atdStartTime...
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.