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 Mike Lewis 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. Stevan23

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

    Hi sabinUE, I think it is now. Thanks for all the help and for teaching me some more about what SQL can do. Have a great rest of the night or day!
  2. Stevan23

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

    Hi sabinUE, I think I've found out why it was showing two results. From the 13/12/2013, the naming of the suppliers changed from Berkana Park to Berkana Park 1 and Berkana Park 2, so when the LEFT(t0.SupplierName,LEN(t0.SupplierName)-2) is taking place after the union all, it shows as...
  3. Stevan23

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

    Hi sabinUE, Thanks for that, I have added the extra columns as you suggested and I'm getting these results: Farm Dscription EggPercent express Berkana Park 55 9.9413602235984 1 Berkana Park Blood 0 1 Berkana Park Crack 3.44531521163296 1 Berkana Park Dirt 6.30057909062677 1 Berkana Park Jumbo...
  4. Stevan23

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

    Hi sabinUE Please find the code below: declare @FromDate as DATE ,@ToDate as DATE SET @FromDate=CONVERT(date, DATEADD(d,-7,getdate())) SET @ToDate=CONVERT(date, getdate()) select (case when SupplierName = 'Cage' then 'Cage' else LEFT(t0.SupplierName,LEN(t0.SupplierName)-2) end) As Farm...
  5. Stevan23

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

    Hi sabinUE, I've made some adjustments to the query where I am only looking at Berkana Park for now and I'm getting the actual results for the last week but also I am receiving the 1 Eggpercent as below: Farm Dscription EggPercent Berkana Park 55 9.9413602235984 Berkana Park Blood 0 Berkana...
  6. Stevan23

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

    Hi SabinUE, Thanks for the help, I've changed the query to look at my view but it also seems to pick up the other farms (example Kerr Farm)? Do I change the first select statement after the Union All to only look for Berkana? select SupplierName,Dscription,EggPercent--,FirstDate from Farm...
  7. Stevan23

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

    Hi SabineUE, I've run the query and that's perfect. I'm presuming I would only need this section for the view (and replace Farm with the name of the view?): select SupplierName,Dscription,EggPercent--,FirstDate from Farm as t0 where t0.FirstDate >= @FromDate and t0.FirstDate <= @ToDate AND...
  8. Stevan23

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

    Hi SabinUE, Thanks for the quick response. Would that still be okay if there is no data for the farm itself? To clarify, the view's data is filled out when the eggs from a farm are graded (suppliername, date etc.) for a date. If no eggs are graded for that farm, the SupplierName, Date etc. is...
  9. Stevan23

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

    Hi all, We are using Microsoft SQL Server 2008 and are querying a SQL view that contains information about our egg grade percentages for each farm. A manager wants as part of the query if a farm does not exist for the last seven days then it is it return a default percentage of one for the...
  10. Stevan23

    Cross tab formula

    Thanks Madawc, sorry about that. We are indeed using Crystal Reports 2008. Several of the rows are formula based (calculating percentages, differences etc). I am struggling to come up with a formula that contains the right logic to perform this calculation. I made a formula using an if then...
  11. Stevan23

    Cross tab formula

    Hi all, We are trying to come up with a forecast report and are trying to calculate the opportunity cost. We have created a formula - ABS(IF(D22<0),(-D22-E22)) - in Excel where this is basically saying if the net quantity difference between the forecast, actual and sales for the second most...

Part and Inventory Search

Back
Top