Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. sabinUE

    Update records based on Count

    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
  2. sabinUE

    Update records based on Count

    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]...
  3. sabinUE

    Help Writing a complicated query

    Welcome! sabin MCP
  4. sabinUE

    Help Writing a complicated query

    ;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...
  5. sabinUE

    modifying table structure

    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...
  6. sabinUE

    Unicode data, stored procedure and SQL Server 2000

    I are right; sry about that sabin MCP
  7. sabinUE

    Unicode data, stored procedure and SQL Server 2000

    Hi, Try to use SqlDbType.NVarChar instead of adVarChar sabin MCP
  8. sabinUE

    If data exists in view return data otherwise return 1 percent for each farm & egg type

    Hi, Glade to help! Have a nice day also! Ce-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mut sabin
  9. sabinUE

    If data exists in view return data otherwise return 1 percent for each farm & egg type

    Hi, I hope that now it's ok. S Ce-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mut sabin
  10. sabinUE

    If data exists in view return data otherwise return 1 percent for each farm & egg 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...
  11. sabinUE

    If data exists in view return data otherwise return 1 percent for each farm & egg type

    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...
  12. sabinUE

    If data exists in view return data otherwise return 1 percent for each farm & egg type

    I've made some adjustments to the query can we see the adjustments ? Ce-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mut sabin
  13. sabinUE

    If data exists in view return data otherwise return 1 percent for each farm & egg type

    u can drop the where condition :AND t0.SupplierName like '%Berkana%' from both selects Ce-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mut sabin
  14. sabinUE

    If data exists in view return data otherwise return 1 percent for each farm & egg type

    Yes, you can try it S Ce-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mut sabin
  15. sabinUE

    If data exists in view return data otherwise return 1 percent for each farm & egg type

    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...
  16. sabinUE

    If data exists in view return data otherwise return 1 percent for each farm & egg type

    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...
  17. sabinUE

    Split a TEXT string at each carriage return

    you can inspire to this http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033 Ce-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mut sabin
  18. sabinUE

    Split a TEXT string at each carriage return

    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]...
  19. sabinUE

    Split a TEXT string at each carriage return

    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
  20. sabinUE

    Query Performance very slow

    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...

Part and Inventory Search

Back
Top