Query on Percent

Hi Experts,
I created a UDF in Item Master data: Percent (units & totals, percents) then I want to get this data (%) thru Query-FMS assigned in the Discount field of Sales Order and will be triggered when the Base Unit is set to No.
Thanks,
Don

Hi Don,
Try this simple one:
SELECT T0.U_Percent FROM OITM T0 WHERE T0.ItemCode = $[$38.1.0\] AND $[$38.12.0\] = 'N'
Thanks,
Gordon

Similar Messages

  • Display the value in millions

    Hi,
        I am designing a pie chart, the output value of the pie chart should be display as 72%($2.75Mil) but it was displaying as 72%(2,752,852). I used the format as 0,,;(0,,) and expression as =" #PERCENT{P0}" & VbCrlf &
    "("&FormatCurrency(IIF(IsNothing(Fields!name) = TRUE, 0, Fields!name.Value), 0)&") ".............
    I tried to use number option and place as millions and avoid commas, but it is not working, Can anybody help on this
    BALUSUSRIHARSHA

    I tried these expressions
    =FormatNumber(CDbl(Fields!name.Value)/1000000,2)+"
    Mil"
    =IIF(Fields!name.Value>1000000,Fields!name.Value+"Mil",Fields!name.Value)
    =IIF(coount(Fields!name.Value)>=7,Fields!name.Value+"Mil",Fields!name.Value)
    At last I tried in query by converting that column into varchar
    case when column>100000 then (column as varchar)+'Mil' else (column as varchar) end as column name.
    This works little better in query but the chart is not displaying at the output in rdl if I use this statement.
    what change we should make in the expression if we use varchar in query?
    ="#PERCENT{P0}" & VbCrlf &("&FormatCurrency(IIF(IsNothing(Fields!name.Value) = TRUE, 0, Fields!name.Value) , 0)&") "
    BALUSUSRIHARSHA

  • Can't seem to get sort-object working in powershell widget

    I'm experiencing a bit of exasperation with the powershell widget in SCOM 2012 - go easy on me though, this is my first time posting and I'm a bit of a newbie with powershell.
    Because of the issues with the logical disk space performance widget and multiple disks (if you have 3 disks attached you get 9 results back) I've been trying to adapt a script somebody else wrote (http://blogs.technet.com/b/lukaszr/archive/2014/06/18/how-to-get-nice-logical-disk-state-view-using-powershell-grid-widget.aspx)
    as I want something slightly different.
    My objective is to list the 10 servers with lowest free GB space. The script I've been trying to adapt just lists all disks on all servers.
    Here is my modified version of the script
    $disklist = @()
    $disks = Get-SCOMClass -Name "Microsoft.Windows.Server.LogicalDisk" | Get-SCOMClassInstance
    foreach ($disk in $disks)
    $query = GET-WMIOBJECT –query "SELECT * from win32_logicaldisk where DeviceID = '$disk'" -ComputerName $disk.Path | Select-Object Size, FreeSpace
    $size = $query.Size
    $free = $query.FreeSpace
    $percent = $free / $size
    $pervalue = "{0:P0}" -f $percent
    $sizeGB = "{0:N1}" -f ($size / 1024 / 1024 / 1024)
    $freeGB = "{0:N1}" -f ($free / 1024 / 1024 / 1024)
    $diskobject = $ScriptContext.CreateFromObject($disk, "Id=Id", $null)
    $diskobject["Server"] = $disk.Path
    $diskobject["Drive"] = $disk.Displayname
    $diskobject["FreeG"] = $freeGB
    $diskobject["FreeP"] = $pervalue
    $diskobject["FreeTotal"] = ($freeGB + " / " + $sizeGB)
    $disklist += $diskobject
    $GBdisklist = $disklist | Sort-Object -Property {[float]($_.FreeG)} | select -first 10
    foreach($thing in $GBdisklist) {
    $ScriptContext.ReturnCollection.Add($thing)
    My thinking was to put all the info into one big collection, then sort that by free disk space and select the top 10, then pipe those back into the scriptcontext collection for displaying. It's slightly unwieldy, granted, but works fine in standard powershell
    (after changing the scriptcontext bits), just not the widget!
    It all seems to work, and brings back data, except the data that comes back has clearly not been sorted before having the top 10 selected. It's as if the sort command is completely ignored. I've tried quite a few variations on the script sort/sort-object
    with or without -property in desperation as I seem to be so close, but yet so far.
    Any help would be appreciated!
    Pete.
    Incidentally, this is the script that works perfectly in standard powershell:
    $disklist = @()
    $disks = Get-SCOMClass -Name "Microsoft.Windows.Server.LogicalDisk" | Get-SCOMClassInstance
    foreach ($disk in $disks)
    $query = GET-WMIOBJECT –query "SELECT * from win32_logicaldisk where DeviceID = '$disk'" -ComputerName $disk.Path | Select-Object Size, FreeSpace
    $size = $query.Size
    $free = $query.FreeSpace
    $percent = $free / $size
    $pervalue = "{0:P0}" -f $percent
    $sizeGB = "{0:N1}" -f ($size / 1024 / 1024 / 1024)
    $freeGB = "{0:N1}" -f ($free / 1024 / 1024 / 1024)
    $diskobject = New-Object System.Object
    $diskobject | Add-Member -MemberType NoteProperty -Name "Id" -Value $disk.ID
    $diskobject | Add-Member -MemberType NoteProperty -Name "Server" -Value $disk.Path
    $diskobject | Add-Member -MemberType NoteProperty -Name "Drive" -Value $disk.Displayname
    $diskobject | Add-Member -MemberType NoteProperty -Name "FreeP" -Value "$pervalue"
    $diskobject | Add-Member -MemberType NoteProperty -Name "FreeG" -Value $freeGB
    $diskobject | Add-Member -MemberType NoteProperty -Name "FreeTotal" -Value ($freeGB + " / " + $sizeGB)
    $disklist += $diskobject
    $GBdisklist = $disklist | Sort-Object -Property {[float]($_.FreeG)} | select -first 10
    $GBdisklist | ft

    After hacking the code around massively I've managed to solve the issue with it and made it a lot neater in the process. Still unsure what the issue was, but I think it helps to sort the output of the diskinfo first before starting with any of the info processing
    / scriptcontext adding
    $disklist = @()
    $rawdisks = Get-SCOMClass -Name "Microsoft.Windows.Server.LogicalDisk" | Get-SCOMClassInstance
    foreach ($disk in $rawdisks)
    $diskdetails = GET-WMIOBJECT –query "SELECT * from win32_logicaldisk where DeviceID = '$disk'" -ComputerName $disk.Path | Select-Object PSComputerName, DeviceID, FreeSpace, Size
    $disklist += $diskdetails
    $top10disks = $disklist | Sort-Object -Property FreeSpace | select -first 10
    foreach ($object in $top10disks) {
    $size = $object.Size
    $free = $object.FreeSpace
    $percent = $free / $size
    $pervalue = "{0:P0}" -f $percent
    $sizeGB = "{0:N1}" -f ($size / 1024 / 1024 / 1024)
    $freeGB = "{0:N1}" -f ($free / 1024 / 1024 / 1024)
    $dataObject = $ScriptContext.CreateInstance("xsd://foo!bar/baz")
    $dataObject["Id"] = (($object.PSComputerName).ToString() + ($object.DeviceID).ToString())
    $dataObject["Server"] = ($object.PSComputerName).ToString()
    $dataObject["Drive"] = $object.DeviceID
    #$dataObject["Free GB"] = ($freeGB).ToString("0000.00")
    $dataObject["Free GB"] = ($freeGB).ToString()
    $dataObject["FreeTotal"] = (($freeGB).ToString() + " / " + ($sizeGB).ToString())
    $ScriptContext.ReturnCollection.Add($dataObject)

  • BEx Query: Percent Share based on characteristic

    My question is around a query that follows this sort of layout:
    Order  |  Doc No.  |  Account  |  Type  |  *Amount*
       1            1          1          A         20
       1            1          2          A         30
       1            2          3          A         40
       2            3          4          A         50
    I want to calculate the percent share by Doc No. so in this example, I'd want it to show like this:
    Order  |  Doc No.  |  Account  |  Type  |  *Amount*  |  *Percent*
       1            1          1          A          20         40%
       1            1          2          A          30         60%
       1            2          3          A          40        100%
       2            3          4          A          50        100%
    I've tried doing a forumla based on amount with Aggregation of summation on Doc No. and that didn't work. I also tried some of the other percent functions but unless the exact doc no. is drilled down on, they show the percent share for the entire report which doesn't work either. Any ideas? I feel like I've done something like this before but can't seem to get it to work! Points to an answer that yields the result I'm looking for!
    Thanks!
    Edited by: Christopher Deaner on Jan 16, 2012 10:55 PM

    Let me see if this example of what I'm seeing makes more sense:
    Order  |  Doc No.  |  Account  |  Type  |  *Amount*  |  *abs(Amount)*  |  *Percent*  | Expected Percent
       1            1          1          A          20            20          200%           40%     
       1            1          2          A         -30            30          300%           60%
                                       +Result+     -10           -10
       1            2          3          A          40            40          100%          100%
       2            3          4          A          50            50          100%          100%
    The absolute value of the Amount column is calculating the result of the original values (with the original signs). This result is being used in the Percent (%CT) calculation which is causing the calculated percent to be wrong. I tried changing the "Calculate Result as" setting to Summation which corrected the result row (in the above example it would show 50 for the abs(Amount) column) but the %CT calculation is still incorrect.

  • OSTC Query Not Showing Correct Percent If Component is Changed

    Hello gurus and experts...here is an interesting question:
    Question:  Why does a query not report proper Sales Tax Code percentage from OSTC table when a component is updated?
    Sales Tax Code (STC) of CA-37B, with a rate of 10.25% is made up of three parts:
    California (CA) State Tax Jurisdiction of "CA" with a rate of 7.00%,
    County Tax Jurisdiction of "CA-37" at a rate of 1.75%,
    City Tax Jurisdiction of "CA-37B" with a rate of 1.50%, and the effective date is set at 31 Dec 2008 (in the past).
    When the City Tax Jurisdiction is changed to 1.00% and date of 31 Dec 2009, the OSTC of CA-37B should be 9.75%.
    However, when a query is run on the OSTC table it strangely reports the old 10.25% (on the Sales Tax Code window it shows correctly as 9.75%).
    Here is the query - very simple...as about as simple as it gets...
    SELECT
    T0.Code,
    T0.Name,
    T0.Rate AS 'Total Tax Percentage',
    T0.Freight AS 'Freight Taxable?'
    FROM OSTC T0
    ORDER BY T0.Code
    IF we go back to the Sales Tax Code Window and change anything (description, one of the components, etc) and hit the update button, then the query reports the correct percentage.
    Am I missing something here?  I would imagine that the system must be doing something and I cannot believe the workaround is just go back and update something in the Sales Tax Code window - there are a ton of updates to do with taxes each year!  Trying to remember which component was updated can cause real confusion.  SAP B1 does a ton of automatic updates all over the system - why would it just be this area of information in OSTC???
    Thanks for reading the post, and many more thanks for your help and suggestions - Zal

    OK - Question Answered - had nothing to do with the query - user did not hit "Update" two times when doing the City Tax Jurisdiction Update...
    I knew SAP would be doing an auto update - has to!!!
    Thanks all - Zal

  • Add and Integrate  3 fields to a Pivot query

    I kept asking questions about this query even after I had marked the thread as answered, and may not have been fair to those who assisted.
    Given the following code, how do I add 2 calculated fields:
    1. Sales - SalesLy as Difference
    2. ((Sales - SalesLY) / SalesLY) * 100 as SalesPercent
    This percent should be 2 digits after decimal point and also check for divide by zero.
    select oracle_key  
    -- "pivot" results
    ,      max(businessdate)   businessdate
    ,      max(sales)          sales
    ,      max(sales_ly)       sales_ly
    ,      max(guests)         guests
    ,      max(guests_ly)      guests_ly
    ,      max(dollarvariance) dollarvariance
    ,      max(wtd_sales)      wtd_sales
    ,      max(wtd_sales_ly)   wtd_sales_ly
    ,      max(wtd_guests)     wtd_guests
    ,      max(wtd_guests_ly)  wtd_guests_ly
    from ( with -- just touching both tables once instead of four times here (subquery factoring)
               totals as ( select d.busi_date
                           ,      d.oracle_key
                           ,      s.storeid
                           ,      d.field1
                           ,      d.field2
                           ,      d.field3
                           -- ,      d.field4 (Cars) doesnt't seem to be part of your final result set?
                           from   mydailytotals d
                           ,      mystores s
                           where  d.oracle_key = s.storeid(+) --<< forgive my 'old school' outer-join ;)
           select oracle_key  
    --       ,      storeid
    --       ,      row_number() over (partition by oracle_key order by busi_date desc) rn      
           -- note: assuming dates are/will become parameters/bind variables in real code...
           -- businesdate
           ,      case
                    when busi_date = to_date('6/4/2009', 'mm/dd/yyyy')
                    then busi_date
                  end as businessdate
           -- sales             
           ,      case
                    when busi_date = to_date('6/4/2009', 'mm/dd/yyyy')
                    then field1
                  end as sales
           -- saleslastyear             
           ,      case
                    when busi_date = to_date('6/5/2008' , 'mm/dd/yyyy')
                    then field1
                  end as sales_ly
           -- guestcount             
           ,      case
                    when busi_date = to_date('6/4/2009', 'mm/dd/yyyy')
                    then field2
                  end as guests
           -- guestcountlastyear             
           ,      case      
                    when busi_date = to_date('6/5/2008', 'mm/dd/yyyy')
                    then field2              
                  end as guests_ly
           -- dollarvariance
           ,      case
                    when busi_date = to_date('6/4/2009', 'mm/dd/yyyy')
                    then field3
                  end as dollarvariance
           -- weektodatesales             
           ,      sum( case
                         when busi_date between to_date('6/1/2009', 'mm/dd/yyyy') and to_date('6/4/2009', 'mm/dd/yyyy')
                         then field1 else 0
                       end
                  as wtd_sales
           -- weektodatesaleslastyear             
           ,      sum( case
                         when busi_date between to_date('6/2/2008', 'mm/dd/yyyy') and to_date('6/5/2008', 'mm/dd/yyyy')
                         then field1 else 0
                       end
                  ) as wtd_sales_ly
           -- weektodateguestcount             
           ,      sum( case
                         when busi_date between to_date('6/1/2009', 'mm/dd/yyyy') and to_date('6/4/2009', 'mm/dd/yyyy')
                         then field2 else 0  
                       end
                  ) as wtd_guests
           -- weektodateguestcountlastyear             
           ,      sum( case
                         when busi_date between to_date('6/2/2008', 'mm/dd/yyyy') and to_date('6/5/2008', 'mm/dd/yyyy')
                        then field2 else 0
                       end
                  ) as wtd_guests_ly
           from totals
           group by oracle_key
           ,        busi_date      
           ,        field1
           ,        field2
           ,        field3      
    group by  oracle_key
    order  by oracle_keySee this post for background:
    Complex Inner Join and subquery on outer where clause on inner join?
    Another question regarding the same. The following query successfully eliminates duplicates in the DollarVariance field.
    How do I integrate into previous query.
    Select StoreId,
               DollarVariance
        from   (select store.storeid,
                        case
                              when inv.fk_str_main_id is null then 'None'
                              when inv.is_posted = 0 then 'NP'
                              else chr(39)||inv.total_dol_var||chr(39)
                         end as DollarVariance ,
                   row_number() over (partition by store.storeid order by inv.is_posted desc) rn 
                   from  valenti_wendys.inv_main inv
                   right outer join valenti_wendys.str_main_mapped_to_storedb store
                                  on store.storeid = inv.fk_str_main_id
                                  and FK_LK_CNT_FREQ_ID = 1
                                  and busi_date = PrevDay)
          where rn = 1;If more information needed, refer to this post:
    URLhttp://forums.oracle.com/forums/thread.jspa?threadID=912671&tstart=60 [URL]
    Thanks in advance

    Yeah, I know, I'm a bit later than planned, about to log off, but I know ;)
    How about:
    select oracle_key  
    -- "pivot" results
    ,      max(businessdate)   businessdate
    ,      max(sales)          sales
    ,      max(sales_ly)       sales_ly
    ,      max(sales) - max(sales_ly) difference
    ,      round(((max(sales) - max(sales_ly))/max(sales_ly)*100), 2) salespercent
    ,      max(guests)         guests
    ,      max(guests_ly)      guests_ly
    ,      max(dollarvariance) dollarvariance
    ,      max(wtd_sales)      wtd_sales
    ,      max(wtd_sales_ly)   wtd_sales_ly
    ,      max(wtd_guests)     wtd_guests
    ,      max(wtd_guests_ly)  wtd_guests_ly
    from ( with -- just touching both tables once instead of four times here (subquery factoring)
               totals as ( select d.busi_date
                           ,      d.oracle_key
                           ,      s.storeid
                           ,      d.field1
                           ,      d.field2
                           ,      d.field3
                           -- ,      d.field4 (Cars) doesnt't seem to be part of your final result set?
                           from   mydailytotals d
                           ,      mystores s
                           where  d.oracle_key = s.storeid(+) --<< forgive my 'old school' outer-join ;)
           select oracle_key  
    --       ,      storeid
    --       ,      row_number() over (partition by oracle_key order by busi_date desc) rn      
           -- note: assuming dates are/will become parameters/bind variables in real code...
           -- businesdate
           ,      case
                    when busi_date = to_date('6/4/2009', 'mm/dd/yyyy')
                    then busi_date
                  end as businessdate
           -- sales             
           ,      case
                    when busi_date = to_date('6/4/2009', 'mm/dd/yyyy')
                    then field1
                  end as sales
           -- saleslastyear             
           ,      case
                    when busi_date = to_date('6/5/2008' , 'mm/dd/yyyy')
                    then field1
                  end as sales_ly
           -- guestcount             
           ,      case
                    when busi_date = to_date('6/4/2009', 'mm/dd/yyyy')
                    then field2
                  end as guests
           -- guestcountlastyear             
           ,      case      
                    when busi_date = to_date('6/5/2008', 'mm/dd/yyyy')
                    then field2              
                  end as guests_ly
           -- dollarvariance
           ,      case
                    when busi_date = to_date('6/4/2009', 'mm/dd/yyyy')
                    then field3
                  end as dollarvariance
           -- weektodatesales             
           ,      sum( case
                         when busi_date between to_date('6/1/2009', 'mm/dd/yyyy') and to_date('6/4/2009', 'mm/dd/yyyy')
                         then field1 else 0
                       end
                  as wtd_sales
           -- weektodatesaleslastyear             
           ,      sum( case
                         when busi_date between to_date('6/2/2008', 'mm/dd/yyyy') and to_date('6/5/2008', 'mm/dd/yyyy')
                         then field1 else 0
                       end
                  ) as wtd_sales_ly
           -- weektodateguestcount             
           ,      sum( case
                         when busi_date between to_date('6/1/2009', 'mm/dd/yyyy') and to_date('6/4/2009', 'mm/dd/yyyy')
                         then field2 else 0  
                       end
                  ) as wtd_guests
           -- weektodateguestcountlastyear             
           ,      sum( case
                         when busi_date between to_date('6/2/2008', 'mm/dd/yyyy') and to_date('6/5/2008', 'mm/dd/yyyy')
                        then field2 else 0
                       end
                  ) as wtd_guests_ly
           from totals
           group by oracle_key
           ,        busi_date      
           ,        field1
           ,        field2
           ,        field3      
    group by  oracle_key
    order  by oracle_key
    notez bien
    +(still) using the data from your original post here+
    Is it not possible, that since you have the fields available in the inner query, you could avoid the need for another? Querying a result set containing all the data you need is less resource intensive than requerying the same data/tables over and over.
    A common way to create reports is to base it on a (smart/dedicated) view, the view would deliver the required output already JAPYR.
    I have a program that produces report already, but in the business logic.Please elaborate on that, so we can understand better what's goin' on.
    Another question regarding the same. The following query successfully eliminates duplicates in the DollarVariance field.
    How do I integrate into previous query. I'll get back on that one tomorrow
    Edited by: hoek on Jun 21, 2009 11:06 PM

  • Is there a way to fix particular percent of slice area to each level value

    Is there a way to fix particular percent of slice area to each level value in a flash pie Chart?
    I need a pie chart for Distribution of Escalations by Status; here I have following status Record in my table
    5 record for Status: Reopen
    2 record for Status: Escalated
    2015 record for Status: Closed
    12 record for Status: Open
    1000 record for Status: WIP
    So I am not able to see data in pie chart for Status Reopen, Escalated, and Open, bcz all levels are overlapping each other
    So I want to fix particular percent of slice area to each level value(Reopen, Escalated, Closed , WIP and Open)
    For e.g. I want to show 15% slice area of chart for Escalated, 10% for Reopen, 20% for Open
    25% for WIP and 30% for Closed. So i can see record for all status while that have less data as compare to other
    status.
    I am using following query for pie Chart….
    SELECT
    ''javascript:dhtml_GetReport_r2(0,0,0,0,0,''''''||''''||STATUS||''''||'''''',0)'' link,
    nvl(STATUS,''Unknown'') label,
    COUNT(ISSUE_ID) Escalations
    FROM XYZ_ITR_MAIN
    WHERE 1=1 GROUP BY STATUS;
    Thanks
    Rathore
    Edited by: Rathore on 01-Apr-2010 02:37

    Your requirement makes sense from the point of visibility but doesn't make sense having the facts in mind that 2 out of 3034 is always 0,000659195% no matter how you look at it. And a pie chart is always going to give you exactly that. The only thing you can do is to manipulate your data but then what a user will see is not going to match with the reality. So, the only solution I see is to make a bigger chart. Exploding a pie chart is also an alternative but I don't think you can do that currently with the flash charts.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

  • Open invoice customer ageing query

    I have set up a query to find a customer aging report - open ivoices. I just want to have open records... does anyone have a better query for this?
    SELECT     TOP (100) PERCENT dbo.OCRD.CardName, dbo.OCRD.Balance, (CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE()) BETWEEN 0 AND
                          30 THEN CASE WHEN T1.SYSCred <> 0 THEN T1.SYSCred * - 1 ELSE T1.SYSDeb END ELSE 0 END) AS [0-30], (CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE())
                          BETWEEN 31 AND 60 THEN CASE WHEN T1.SYSCred <> 0 THEN T1.SYSCred * - 1 ELSE T1.SYSDeb END ELSE 0 END) AS [31-60], (CASE WHEN DATEDIFF(DD,
                          T0.REFDATE, GETDATE()) BETWEEN 61 AND 90 THEN CASE WHEN T1.SYSCred <> 0 THEN T1.SYSCred * - 1 ELSE T1.SYSDeb END ELSE 0 END) AS [61-90],
                          (CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE()) > 91 THEN CASE WHEN T1.SYSCred <> 0 THEN T1.SYSCred * - 1 ELSE T1.SYSDeb END ELSE 0 END) AS [90+],
                          dbo.OCRD.CardType, T1.TransType, T1.TransCode, T1.LineMemo, T1.BaseRef, dbo.OCRD.CardCode, T1.BalDueDeb
    FROM         dbo.OJDT AS T0 INNER JOIN
                          dbo.JDT1 AS T1 ON T1.TransId = T0.TransId INNER JOIN
                          dbo.OCRD ON dbo.OCRD.CardCode = T1.ShortName
    WHERE     (dbo.OCRD.Balance >= 1) AND (dbo.OCRD.CardType = 'C') AND (T1.BalDueDeb > 0)
    ORDER BY dbo.OCRD.CardName
    Regards,
    knut

    Knut,
    Try this:
    SELECT T2.CardName, T2.Balance,
    (CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE()) BETWEEN 0 AND
    30 THEN CASE WHEN T1.SYSCred != 0 THEN -T1.SYSCred ELSE T1.SYSDeb END ELSE 0 END) AS '0-30',
    (CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE()) BETWEEN 31 AND
    60 THEN CASE WHEN T1.SYSCred != 0 THEN -T1.SYSCred ELSE T1.SYSDeb END ELSE 0 END) AS '31-60',
    (CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE()) BETWEEN 61 AND
    90 THEN CASE WHEN T1.SYSCred != 0 THEN -T1.SYSCred ELSE T1.SYSDeb END ELSE 0 END) AS '61-90',
    (CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE()) >90
    THEN CASE WHEN T1.SYSCred != 0 THEN -T1.SYSCred ELSE T1.SYSDeb END ELSE 0 END) AS '90+',
    T1.TransType, T1.TransCode, T1.LineMemo, T1.BaseRef, T2.CardCode
    FROM dbo.OJDT T0
    INNER JOIN dbo.JDT1 T1 ON T1.TransId = T0.TransId
    INNER JOIN dbo.OCRD T2 ON T2.CardCode = T1.ShortName
    WHERE (T2.Balance >= 1) AND (T2.CardType = 'C') AND (T1.BalDueDeb != T1.BalDueCred)
    Thanks,
    Gordon

  • SQL Query Performance Issue

    Hey,
    Please forgive me if I'm missing something really obvious but it's been a while since I did any SQL work and I'm obviously a bit rusty.
    When the below query is run the CPU on the SQL server maxes out. The query itself takes over 6 hours to run.
    Is there anything glaringly obvious with the query that might be causing thisCheers
    Paul
    SELECT TOP (100) PERCENT dbo.CUSTPACKINGSLIPTRANS.ITEMID AS [Stock Code],
    dbo.CUSTPACKINGSLIPTRANS.SALESUNIT AS [Unit of Sale],
    dbo.DIMENSIONFINANCIALTAG.DESCRIPTION AS [Product Group],
    dbo.INVENTITEMGROUP.ITEMGROUPID AS [Item Group],
    dbo.INVENTTABLE.SECTION,
    dbo.INVENTTABLE.GROUPS AS [Group],
    dbo.INVENTTABLE.SUBGROUPS AS [Sub Group],
    dbo.CUSTPACKINGSLIPJOUR.ORDERACCOUNT AS [Cust Account],
    dbo.CUSTTABLE.INVOICEACCOUNT AS [Invoice Account],
    dbo.DIRPARTYTABLE.NAME AS [Cust Name],
    dbo.CUSTTABLE.CURRENCY,
    dbo.CUSTTABLE.CIT_CONTROLLER AS [Credit Controller],
    dbo.CUSTTABLE.CREDITMAX AS [Credit Limit],
    dbo.CUSTTABLE.CUSTCLASSIFICATIONID AS Classification,
    dbo.DIRPERSONNAME.FIRSTNAME + ' ' + dbo.DIRPERSONNAME.LASTNAME AS [Sales Person],
    dbo.SALESTABLE.SALESGROUP AS [Outside Rooms],
    CASE WHEN CUSTTABLE.CUSTCLASSIFICATIONID = 'Cash' THEN dbo.SALESTABLE.SALESGROUP ELSE dbo.CUSTTABLE.SALESGROUP END AS [Sales Rep],
    dbo.LOGISTICSPOSTALADDRESS.STATE [Customer Region],
    dbo.LOGISTICSPOSTALADDRESS.COUNTY [Customer County],
    dbo.CUSTTABLE.LINEOFBUSINESSID AS [Line Of Business],
    a.DISPLAYVALUE AS [Site/Location],
    dbo.CUSTPACKINGSLIPTRANS.PACKINGSLIPID AS [Delivery Ref],
    dbo.LOGISTICSPOSTALADDRESS.COUNTRYREGIONID,
    CONVERT(varchar(12), dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE, 111) AS [Delivery Date],
    dbo.LOGISTICSPOSTALADDRESS.ADDRESS AS [Delivery Address],
    dbo.CUSTPACKINGSLIPTRANS.VALUEMST AS [Delivery Value (CON)],
    CONVERT(varchar(12), dbo.SALESTABLE.RECEIPTDATEREQUESTED, 111) AS [Requested Delivery Date],
    dbo.SALESTABLE.SALESID AS [Order Ref],
    CASE dbo.SALESTABLE.SALESSTATUS WHEN '0' THEN 'None' WHEN '1' THEN 'Open Order' WHEN '2' THEN 'Delivered' WHEN '3' THEN 'Invoiced' WHEN '4' THEN 'Canceled' END AS [Sales Status],
    CASE dbo.SALESTABLE.SALESTYPE WHEN '0' THEN 'Journal' WHEN '1' THEN 'Quotation' WHEN '2' THEN 'Subscription' WHEN '3' THEN 'Sales Order' WHEN '4' THEN 'Returned Item' WHEN '5' THEN 'Blanket Order' WHEN '6' THEN 'Item Requirements' WHEN '7' THEN 'Undefined' END AS [Sales Type],
    CASE dbo.SALESTABLE.AG_SALESLOCATION WHEN '0' THEN 'None' WHEN '1' THEN 'OR_DGN' WHEN '2' THEN 'OR_FMT' WHEN '3' THEN 'OR_TME' WHEN '4' THEN 'OR_OMA' WHEN '5' THEN 'DSP_DGN' WHEN '6' THEN 'DSP_FMT' WHEN '7' THEN 'DSP_TME' WHEN '8' THEN 'DSP_OMA' WHEN '9' THEN 'DSP_BEL' WHEN '10' THEN 'DSP_CDF' WHEN '11' THEN 'DSP_BGY' WHEN '12' THEN 'Credit Control' WHEN '13' THEN 'Internal Sales' WHEN '14' THEN 'CP_FMT' WHEN '15' THEN 'GBSales' END AS [Sales Location],
    dbo.SALESTABLE.PURCHORDERFORMNUM AS [Customer Requisition],
    dbo.SALESLINE.LINEDISC AS [Line Disc],
    dbo.SALESLINE.LINEPERCENT AS [Line Percent],
    dbo.SALESLINE.PRICEGROUPID AS [Price Group],
    dbo.INVENTDIM.INVENTLOCATIONID AS Warehouse,
    dbo.DIRPARTYTABLE.NAMEALIAS AS [Search Name],
    dbo.CUSTPACKINGSLIPJOUR.LORRYID AS [Lorry ID],
    dbo.CUSTPACKINGSLIPJOUR.LORRYREGNO AS [Lorry Reg],
    dbo.CUSTPACKINGSLIPJOUR.LORRYDRIVER AS [Lorry Driver],
    CASE dbo.SALESLINE.BLOCKED WHEN '0' THEN 'No' WHEN '1' THEN 'Yes' END AS [Stopped?],
    dbo.CUSTPACKINGSLIPTRANS.QTY AS [Qty Delivered],
    dbo.SALESLINE.SALESPRICE AS [Unit Price],
    dbo.CUSTPACKINGSLIPJOUR.CREATEDBY AS [SDN Creator],
    MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) AS Month,
    YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) AS Year,
    DATEPART(week, dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) AS WeekNo,
    CASE MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) WHEN '1' THEN '10' WHEN '2' THEN '11' WHEN '3' THEN '12' WHEN '4' THEN '1' WHEN '5' THEN '2' WHEN '6' THEN '3' WHEN '7' THEN '4' WHEN '8' THEN '5' WHEN '9' THEN '6' WHEN '10' THEN '7' WHEN '11' THEN '8' WHEN '12' THEN '9' END AS [Fin Period], CASE WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) <= '3' THEN CONVERT(VARCHAR(10), (YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) - 1)) + '/' + CONVERT(VARCHAR(10), YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE)) WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) >= '4' THEN CONVERT(VARCHAR(10), YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE)) + '/' + CONVERT(VARCHAR(10), (YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) + 1)) END AS [Fin Year],
    CASE WHEN dbo.custpackingsliptrans.salesunit = '100' THEN dbo.CUSTPACKINGSLIPTRANS.SALESUNIT * dbo.CUSTPACKINGSLIPTRANS.QTY WHEN dbo.custpackingsliptrans.salesunit = '1000' THEN dbo.CUSTPACKINGSLIPTRANS.SALESUNIT * dbo.CUSTPACKINGSLIPTRANS.QTY ELSE dbo.CUSTPACKINGSLIPTRANS.QTY END AS [No of Units],
    CASE dbo.INVENTITEMGROUPITEM.ITEMGROUPID WHEN 'Mortar' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Sand' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Decorative Gravel' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Crushed Aggregates' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Lintels' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) / 1000 WHEN 'TBeams' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) / 1000 WHEN 'Aggregates' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Lime' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY * dbo.UNITOFMEASURECONVERSION.FACTOR) WHEN 'Readymix' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) / 1000 ELSE (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY * dbo.UNITOFMEASURECONVERSION.FACTOR) / 1000 END AS Tonnage,
    dbo.INVENTTABLE.NETWEIGHT AS [Net Weight],
    dbo.INVENTTABLE.PRODCOSTA,
    dbo.INVENTTABLE.PRODCOSTB,
    dbo.INVENTTABLE.PRODCOSTC,
    dbo.INVENTTABLE.PRODCOSTD,
    dbo.INVENTTABLE.PRODCOSTE,
    dbo.INVENTTABLE.PRODCOSTF,
    dbo.INVENTTABLE.PRODCOSTG,
    dbo.INVENTTABLE.PRODCOSTH,
    dbo.INVENTTABLE.QTYPERBALE,
    dbo.INVENTTABLE.M2PERBALE,
    dbo.SALESTABLE.SALESTYPE,
    dbo.SALESTABLE.DLVMODE AS [Delivery Mode],
    CONVERT(varchar(12), dbo.SALESTABLE.SHIPPINGDATECONFIRMED, 111) AS [Shipping Date Confirmed],
    CONVERT(varchar(12), dbo.SALESTABLE.CREATEDDATETIME, 111) AS [Created Date],
    dbo.SALESLINE.CUSTGROUP AS [Cust Group],
    dbo.INVENTTABLE.MADETOORDER AS [Made To Order]
    FROM dbo.CUSTPACKINGSLIPTRANS INNER JOIN
    dbo.CUSTPACKINGSLIPJOUR ON dbo.CUSTPACKINGSLIPTRANS.PACKINGSLIPID = dbo.CUSTPACKINGSLIPJOUR.PACKINGSLIPID INNER JOIN
    dbo.SALESLINE ON dbo.CUSTPACKINGSLIPJOUR.SALESID = dbo.SALESLINE.SALESID AND
    dbo.CUSTPACKINGSLIPTRANS.INVENTTRANSID = dbo.SALESLINE.INVENTTRANSID INNER JOIN
    dbo.INVENTTABLE ON dbo.CUSTPACKINGSLIPTRANS.ITEMID = dbo.INVENTTABLE.ITEMID INNER JOIN
    dbo.INVENTITEMGROUPITEM ON dbo.INVENTTABLE.ITEMID = dbo.INVENTITEMGROUPITEM.ITEMID INNER JOIN
    dbo.INVENTITEMGROUP ON dbo.INVENTITEMGROUPITEM.ITEMGROUPID = dbo.INVENTITEMGROUP.ITEMGROUPID INNER JOIN
    dbo.INVENTDIM ON dbo.SALESLINE.INVENTDIMID = dbo.INVENTDIM.INVENTDIMID INNER JOIN
    dbo.CUSTTABLE ON dbo.CUSTPACKINGSLIPJOUR.ORDERACCOUNT = dbo.CUSTTABLE.ACCOUNTNUM INNER JOIN
    dbo.DIRPARTYTABLE ON dbo.CUSTTABLE.PARTY = dbo.DIRPARTYTABLE.RECID INNER JOIN
    dbo.LOGISTICSPOSTALADDRESS ON dbo.DIRPARTYTABLE.PRIMARYADDRESSLOCATION = dbo.LOGISTICSPOSTALADDRESS.LOCATION INNER JOIN
    dbo.SALESTABLE ON dbo.SALESLINE.SALESID = dbo.SALESTABLE.SALESID INNER JOIN
    dbo.DIRPERSONNAME ON dbo.SALESTABLE.WORKERSALESTAKER = dbo.DIRPERSONNAME.RECID INNER JOIN
    dbo.ECORESPRODUCT ON dbo.CUSTPACKINGSLIPTRANS.ITEMID = dbo.ECORESPRODUCT.SEARCHNAME
    AND dbo.INVENTTABLE.ITEMID = dbo.ECORESPRODUCT.DISPLAYPRODUCTNUMBER LEFT OUTER JOIN
    dbo.UNITOFMEASURECONVERSION ON dbo.ECORESPRODUCT.RECID = dbo.UNITOFMEASURECONVERSION.PRODUCT LEFT OUTER JOIN
    dbo.UNITOFMEASURE ON dbo.UNITOFMEASURECONVERSION.TOUNITOFMEASURE = dbo.UNITOFMEASURE.RECID INNER JOIN
    dbo.DEFAULTDIMENSIONVIEW a ON dbo.CUSTPACKINGSLIPTRANS.DEFAULTDIMENSION = a.DEFAULTDIMENSION AND a.NAME = 'Department' LEFT OUTER JOIN
    dbo.DEFAULTDIMENSIONVIEW b ON dbo.INVENTTABLE.DEFAULTDIMENSION = b.DEFAULTDIMENSION AND b.NAME = 'Center' INNER JOIN
    dbo.DIMENSIONFINANCIALTAG ON b.ENTITYINSTANCE = dbo.DIMENSIONFINANCIALTAG.RECID
    WHERE (dbo.CUSTPACKINGSLIPTRANS.DATAAREAID = 'agl') AND
    (dbo.CUSTPACKINGSLIPJOUR.DATAAREAID = 'agl') AND
    (dbo.SALESLINE.DATAAREAID = 'agl') AND
    (dbo.INVENTTABLE.DATAAREAID = 'vuk') AND
    (dbo.INVENTDIM.DATAAREAID = 'agl') AND
    (dbo.CUSTTABLE.DATAAREAID = 'agl') AND
    (dbo.SALESTABLE.DATAAREAID = 'agl') AND
    (CASE WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) <= '3' THEN (YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) - 1)
    WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) >= '4' THEN YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) END = 2014)

    Hey,
    Please forgive me if I'm missing something really obvious but it's been a while since I did any SQL work and I'm obviously a bit rusty.
    When the below query is run the CPU on the SQL server maxes out. The query itself takes over 6 hours to run.
    Is there anything glaringly obvious with the query that might be causing thisCheers
    Paul
    SELECT TOP (100) PERCENT dbo.CUSTPACKINGSLIPTRANS.ITEMID AS [Stock Code],
    dbo.CUSTPACKINGSLIPTRANS.SALESUNIT AS [Unit of Sale],
    dbo.DIMENSIONFINANCIALTAG.DESCRIPTION AS [Product Group],
    dbo.INVENTITEMGROUP.ITEMGROUPID AS [Item Group],
    dbo.INVENTTABLE.SECTION,
    dbo.INVENTTABLE.GROUPS AS [Group],
    dbo.INVENTTABLE.SUBGROUPS AS [Sub Group],
    dbo.CUSTPACKINGSLIPJOUR.ORDERACCOUNT AS [Cust Account],
    dbo.CUSTTABLE.INVOICEACCOUNT AS [Invoice Account],
    dbo.DIRPARTYTABLE.NAME AS [Cust Name],
    dbo.CUSTTABLE.CURRENCY,
    dbo.CUSTTABLE.CIT_CONTROLLER AS [Credit Controller],
    dbo.CUSTTABLE.CREDITMAX AS [Credit Limit],
    dbo.CUSTTABLE.CUSTCLASSIFICATIONID AS Classification,
    dbo.DIRPERSONNAME.FIRSTNAME + ' ' + dbo.DIRPERSONNAME.LASTNAME AS [Sales Person],
    dbo.SALESTABLE.SALESGROUP AS [Outside Rooms],
    CASE WHEN CUSTTABLE.CUSTCLASSIFICATIONID = 'Cash' THEN dbo.SALESTABLE.SALESGROUP ELSE dbo.CUSTTABLE.SALESGROUP END AS [Sales Rep],
    dbo.LOGISTICSPOSTALADDRESS.STATE [Customer Region],
    dbo.LOGISTICSPOSTALADDRESS.COUNTY [Customer County],
    dbo.CUSTTABLE.LINEOFBUSINESSID AS [Line Of Business],
    a.DISPLAYVALUE AS [Site/Location],
    dbo.CUSTPACKINGSLIPTRANS.PACKINGSLIPID AS [Delivery Ref],
    dbo.LOGISTICSPOSTALADDRESS.COUNTRYREGIONID,
    CONVERT(varchar(12), dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE, 111) AS [Delivery Date],
    dbo.LOGISTICSPOSTALADDRESS.ADDRESS AS [Delivery Address],
    dbo.CUSTPACKINGSLIPTRANS.VALUEMST AS [Delivery Value (CON)],
    CONVERT(varchar(12), dbo.SALESTABLE.RECEIPTDATEREQUESTED, 111) AS [Requested Delivery Date],
    dbo.SALESTABLE.SALESID AS [Order Ref],
    CASE dbo.SALESTABLE.SALESSTATUS WHEN '0' THEN 'None' WHEN '1' THEN 'Open Order' WHEN '2' THEN 'Delivered' WHEN '3' THEN 'Invoiced' WHEN '4' THEN 'Canceled' END AS [Sales Status],
    CASE dbo.SALESTABLE.SALESTYPE WHEN '0' THEN 'Journal' WHEN '1' THEN 'Quotation' WHEN '2' THEN 'Subscription' WHEN '3' THEN 'Sales Order' WHEN '4' THEN 'Returned Item' WHEN '5' THEN 'Blanket Order' WHEN '6' THEN 'Item Requirements' WHEN '7' THEN 'Undefined' END AS [Sales Type],
    CASE dbo.SALESTABLE.AG_SALESLOCATION WHEN '0' THEN 'None' WHEN '1' THEN 'OR_DGN' WHEN '2' THEN 'OR_FMT' WHEN '3' THEN 'OR_TME' WHEN '4' THEN 'OR_OMA' WHEN '5' THEN 'DSP_DGN' WHEN '6' THEN 'DSP_FMT' WHEN '7' THEN 'DSP_TME' WHEN '8' THEN 'DSP_OMA' WHEN '9' THEN 'DSP_BEL' WHEN '10' THEN 'DSP_CDF' WHEN '11' THEN 'DSP_BGY' WHEN '12' THEN 'Credit Control' WHEN '13' THEN 'Internal Sales' WHEN '14' THEN 'CP_FMT' WHEN '15' THEN 'GBSales' END AS [Sales Location],
    dbo.SALESTABLE.PURCHORDERFORMNUM AS [Customer Requisition],
    dbo.SALESLINE.LINEDISC AS [Line Disc],
    dbo.SALESLINE.LINEPERCENT AS [Line Percent],
    dbo.SALESLINE.PRICEGROUPID AS [Price Group],
    dbo.INVENTDIM.INVENTLOCATIONID AS Warehouse,
    dbo.DIRPARTYTABLE.NAMEALIAS AS [Search Name],
    dbo.CUSTPACKINGSLIPJOUR.LORRYID AS [Lorry ID],
    dbo.CUSTPACKINGSLIPJOUR.LORRYREGNO AS [Lorry Reg],
    dbo.CUSTPACKINGSLIPJOUR.LORRYDRIVER AS [Lorry Driver],
    CASE dbo.SALESLINE.BLOCKED WHEN '0' THEN 'No' WHEN '1' THEN 'Yes' END AS [Stopped?],
    dbo.CUSTPACKINGSLIPTRANS.QTY AS [Qty Delivered],
    dbo.SALESLINE.SALESPRICE AS [Unit Price],
    dbo.CUSTPACKINGSLIPJOUR.CREATEDBY AS [SDN Creator],
    MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) AS Month,
    YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) AS Year,
    DATEPART(week, dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) AS WeekNo,
    CASE MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) WHEN '1' THEN '10' WHEN '2' THEN '11' WHEN '3' THEN '12' WHEN '4' THEN '1' WHEN '5' THEN '2' WHEN '6' THEN '3' WHEN '7' THEN '4' WHEN '8' THEN '5' WHEN '9' THEN '6' WHEN '10' THEN '7' WHEN '11' THEN '8' WHEN '12' THEN '9' END AS [Fin Period], CASE WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) <= '3' THEN CONVERT(VARCHAR(10), (YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) - 1)) + '/' + CONVERT(VARCHAR(10), YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE)) WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) >= '4' THEN CONVERT(VARCHAR(10), YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE)) + '/' + CONVERT(VARCHAR(10), (YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) + 1)) END AS [Fin Year],
    CASE WHEN dbo.custpackingsliptrans.salesunit = '100' THEN dbo.CUSTPACKINGSLIPTRANS.SALESUNIT * dbo.CUSTPACKINGSLIPTRANS.QTY WHEN dbo.custpackingsliptrans.salesunit = '1000' THEN dbo.CUSTPACKINGSLIPTRANS.SALESUNIT * dbo.CUSTPACKINGSLIPTRANS.QTY ELSE dbo.CUSTPACKINGSLIPTRANS.QTY END AS [No of Units],
    CASE dbo.INVENTITEMGROUPITEM.ITEMGROUPID WHEN 'Mortar' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Sand' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Decorative Gravel' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Crushed Aggregates' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Lintels' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) / 1000 WHEN 'TBeams' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) / 1000 WHEN 'Aggregates' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) WHEN 'Lime' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY * dbo.UNITOFMEASURECONVERSION.FACTOR) WHEN 'Readymix' THEN (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY) / 1000 ELSE (dbo.INVENTTABLE.NETWEIGHT * dbo.CUSTPACKINGSLIPTRANS.QTY * dbo.UNITOFMEASURECONVERSION.FACTOR) / 1000 END AS Tonnage,
    dbo.INVENTTABLE.NETWEIGHT AS [Net Weight],
    dbo.INVENTTABLE.PRODCOSTA,
    dbo.INVENTTABLE.PRODCOSTB,
    dbo.INVENTTABLE.PRODCOSTC,
    dbo.INVENTTABLE.PRODCOSTD,
    dbo.INVENTTABLE.PRODCOSTE,
    dbo.INVENTTABLE.PRODCOSTF,
    dbo.INVENTTABLE.PRODCOSTG,
    dbo.INVENTTABLE.PRODCOSTH,
    dbo.INVENTTABLE.QTYPERBALE,
    dbo.INVENTTABLE.M2PERBALE,
    dbo.SALESTABLE.SALESTYPE,
    dbo.SALESTABLE.DLVMODE AS [Delivery Mode],
    CONVERT(varchar(12), dbo.SALESTABLE.SHIPPINGDATECONFIRMED, 111) AS [Shipping Date Confirmed],
    CONVERT(varchar(12), dbo.SALESTABLE.CREATEDDATETIME, 111) AS [Created Date],
    dbo.SALESLINE.CUSTGROUP AS [Cust Group],
    dbo.INVENTTABLE.MADETOORDER AS [Made To Order]
    FROM dbo.CUSTPACKINGSLIPTRANS INNER JOIN
    dbo.CUSTPACKINGSLIPJOUR ON dbo.CUSTPACKINGSLIPTRANS.PACKINGSLIPID = dbo.CUSTPACKINGSLIPJOUR.PACKINGSLIPID INNER JOIN
    dbo.SALESLINE ON dbo.CUSTPACKINGSLIPJOUR.SALESID = dbo.SALESLINE.SALESID AND
    dbo.CUSTPACKINGSLIPTRANS.INVENTTRANSID = dbo.SALESLINE.INVENTTRANSID INNER JOIN
    dbo.INVENTTABLE ON dbo.CUSTPACKINGSLIPTRANS.ITEMID = dbo.INVENTTABLE.ITEMID INNER JOIN
    dbo.INVENTITEMGROUPITEM ON dbo.INVENTTABLE.ITEMID = dbo.INVENTITEMGROUPITEM.ITEMID INNER JOIN
    dbo.INVENTITEMGROUP ON dbo.INVENTITEMGROUPITEM.ITEMGROUPID = dbo.INVENTITEMGROUP.ITEMGROUPID INNER JOIN
    dbo.INVENTDIM ON dbo.SALESLINE.INVENTDIMID = dbo.INVENTDIM.INVENTDIMID INNER JOIN
    dbo.CUSTTABLE ON dbo.CUSTPACKINGSLIPJOUR.ORDERACCOUNT = dbo.CUSTTABLE.ACCOUNTNUM INNER JOIN
    dbo.DIRPARTYTABLE ON dbo.CUSTTABLE.PARTY = dbo.DIRPARTYTABLE.RECID INNER JOIN
    dbo.LOGISTICSPOSTALADDRESS ON dbo.DIRPARTYTABLE.PRIMARYADDRESSLOCATION = dbo.LOGISTICSPOSTALADDRESS.LOCATION INNER JOIN
    dbo.SALESTABLE ON dbo.SALESLINE.SALESID = dbo.SALESTABLE.SALESID INNER JOIN
    dbo.DIRPERSONNAME ON dbo.SALESTABLE.WORKERSALESTAKER = dbo.DIRPERSONNAME.RECID INNER JOIN
    dbo.ECORESPRODUCT ON dbo.CUSTPACKINGSLIPTRANS.ITEMID = dbo.ECORESPRODUCT.SEARCHNAME
    AND dbo.INVENTTABLE.ITEMID = dbo.ECORESPRODUCT.DISPLAYPRODUCTNUMBER LEFT OUTER JOIN
    dbo.UNITOFMEASURECONVERSION ON dbo.ECORESPRODUCT.RECID = dbo.UNITOFMEASURECONVERSION.PRODUCT LEFT OUTER JOIN
    dbo.UNITOFMEASURE ON dbo.UNITOFMEASURECONVERSION.TOUNITOFMEASURE = dbo.UNITOFMEASURE.RECID INNER JOIN
    dbo.DEFAULTDIMENSIONVIEW a ON dbo.CUSTPACKINGSLIPTRANS.DEFAULTDIMENSION = a.DEFAULTDIMENSION AND a.NAME = 'Department' LEFT OUTER JOIN
    dbo.DEFAULTDIMENSIONVIEW b ON dbo.INVENTTABLE.DEFAULTDIMENSION = b.DEFAULTDIMENSION AND b.NAME = 'Center' INNER JOIN
    dbo.DIMENSIONFINANCIALTAG ON b.ENTITYINSTANCE = dbo.DIMENSIONFINANCIALTAG.RECID
    WHERE (dbo.CUSTPACKINGSLIPTRANS.DATAAREAID = 'agl') AND
    (dbo.CUSTPACKINGSLIPJOUR.DATAAREAID = 'agl') AND
    (dbo.SALESLINE.DATAAREAID = 'agl') AND
    (dbo.INVENTTABLE.DATAAREAID = 'vuk') AND
    (dbo.INVENTDIM.DATAAREAID = 'agl') AND
    (dbo.CUSTTABLE.DATAAREAID = 'agl') AND
    (dbo.SALESTABLE.DATAAREAID = 'agl') AND
    (CASE WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) <= '3' THEN (YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) - 1)
    WHEN MONTH(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) >= '4' THEN YEAR(dbo.CUSTPACKINGSLIPTRANS.DELIVERYDATE) END = 2014)
    Try to minimize joins using intermediary tables, also you can consider limiting data based on date ranges and codes (DATAAREAID) before joining with other tables.

  • Query in BW 3.5 on cube "customer service"

    Dear Experts,
    in BW 3.5 we created a formula variable in a query to show the difference between two dates. In this case we compare the "confirmed delivery date" and the "real delivery date" and we are now shown the difference in days.
    With this result we have to show in the report, how many percent of the ordernumbers were delivered in time and in what time the orders were delivered which were not right on time.
    Can you show me the steps to do so in the query?
    Thanks in advance,
    regards
    Marc

    Hi SS,
    On a generalized basis the query 0TCT_MC11_Q0240 would give the complete detail about a particular infoprovider. You will have to install this query from the BI content.
    Basically you would get the following details from this query for any infoprovider in you BI system.
    Number of technically incorrect requests
    Number of qualitatively incorrect requests
    Number of erroneous requests
    Number of uncompressed requests
    Number of not aggregated requests
    Number of requests
    Number of technically incorrect records
    Number of qualitatively incorrect records
    Number of erroneous records
    Number of uncompressed records
    Number of not aggregated records
    Number of records
    InfoCube status (regarding requests and records)
    Hope this helps u.
    regards,
    Sree.
    Edited by: Sree Nair on Sep 15, 2009 12:42 PM

  • Width of field in Report From SQL Query

    I have created a report from SQL query with 15 columns being selected. However, no matter what column width and column type (pixel, char, percent) I enter in the column formatting tab of the report, I cannot get the report to format the column to the width I desire. It is always a fixed width. Does anyone have any suggestions?
    Thanks,
    Martin

    Hi,
    Char (used for ASCII format)
    Displays the output in the specified number of
    characters per line. For example, if you enter 20
    in Width, the report displays 20 characters of the
    column data in each line. If the number of
    characters per line exceeds the specified
    number, the remaining characters are wrapped
    to the next line.
    Pixel
    Displays the output in the specified number of
    pixels per row. For example, if you enter 10 in
    Width, the column data displays 10 pixels of
    data per line of the displayed table.
    Percent
    Displays the output in the specified percentage
    of the table. For example, if you enter 25 in
    Width, the column data displays in 25% of the
    displayed table.
    Thanks,
    Sharmila

  • How do I query ink level in Epson CX3650 with printer-gui

    Hi,
    When using the printer gui in KDE to query the ink level on my Epson Stylus CX3650 I get the following error message
    Cannot open /Stylus CX3600 read/write: No such file or directory
    But when I use the command line tool I get
    [rene@archer mtink]$ escputil -i -r /dev/usb/lp0
    Escputil version 5.0.1, Copyright (C) 2000-2006 Robert Krawitz
    Escputil comes with ABSOLUTELY NO WARRANTY; for details type 'escputil -l'
    This is free software, and you are welcome to redistribute it
    under certain conditions; type 'escputil -l' for details.
    Ink color Percent remaining
    Cyan 22
    Magenta 26
    Yellow 27
    Photo Black 55
    Has anyone noticed the same problem, and perhaps know why the gui doesn't work?
    My user is in the following groups
    [rene@archer mtink]$ groups rene
    lp wheel video audio optical floppy storage users
    The commands "Clean print head" and "Print nozzle test pattern" work fine in the gui.
    The commands "Align print head" and "Printer identification" gives the error
    Error
    Please specify a raw device
    I have in other distros succesfuly used mtink to query the ink level, but when I tried building it from aur, I get a dependency problem with gimp-tool. I'll post a seperate post about that in the aur section later. (I'd rather get the kde printer gui to work first ).

    With pleasure!
    Great to know it worked for you
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • Reg: Query group by problem

    Hi,
    I am trying to write query for report generation.According to my client requirment I need to calculate the difference
    between two date columns for "n" number of rows and i need to find the number of rows which are smaller
    than 2 and number of rows which are greater than 2 and calculate the percentage for number of rows which are smaller than 2.
    It must grouped by a third column
    I tried like this, but it shows that date column is not a grouped .....
    But I dont want to group that date column... Plz adivce....
    SELECT table1.column2,
          table2.column3,
          COUNT(*),
         CASE
                 WHEN TO_NUMBER (table1.DTT_column3 - table1.DTT_column4) <=2
                 THEN COUNT(*)
                 ELSE NULL
            END
             AS sucess_count,
         CASE
                 WHEN TO_NUMBER (table1.DTT_column3 - table1.DTT_column4) >2
                 THEN COUNT(*)
                 ELSE NULL
            END
            AS fail_count,
         FROM
         table1,
         table2
         WHERE table1.column1 =       table2.column2
         AND table1.column4 = value1
         GROUP BY table1.column2,table2.column3;TIA,
    Message was edited by: ORCL
    ORCLDB

    May be something like this.
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bi
    PL/SQL Release 10.2.0.2.0 - Production
    CORE    10.2.0.2.0      Production
    TNS for HPUX: Version 10.2.0.2.0 - Production
    NLSRTL Version 10.2.0.2.0 - Production
      1  with t
      2  as
      3  (select 1 id, to_date('01.02.2008','dd.mm.yyyy') date_1,
      4                to_date('03.02.2008','dd.mm.yyyy') date_2 from dual union all
      5   select 1,    to_date('03.02.2008','dd.mm.yyyy'),
      6                to_date('04.02.2008','dd.mm.yyyy') from dual union all
      7   select 2,    to_date('05.02.2008','dd.mm.yyyy'),
      8                to_date('06.02.2008','dd.mm.yyyy') from dual union all
      9   select 2,    to_date('01.02.2008','dd.mm.yyyy'),
    10                to_date('05.02.2008','dd.mm.yyyy') from dual
    11  )
    12  select count(case when to_number(date_2 - date_1) <= 2 then 1 end) diff_2,
    13        count(case when to_number(date_2 - date_1) > 2 then 1 end) diff_Greater_2,
    14    1 - (  count(case when to_number(date_2 - date_1) > 2 then 1 end)
    15         / count(case when to_number(date_2 - date_1) <= 2 then 1 end)
    16        ) percent
    17  from t
    18  group by rollup(id)
    19* having grouping_id(id) = 1
    SQL> /
        DIFF_2 DIFF_GREATER_2    PERCENT
             3              1 .666666667It will be always useful if you could post your full oracle version and a sample test data.
    Regards
    Raj

  • Index rules in oracle text and query using matches

    Dear All,
    I would like to ask about rules and matches function in oracle text.
    I followed an example in oracle text application developer's guide.
    I have a rule table like this :
    1 oracle
    2 larry or ellison
    3 oracle and text
    4 market share
    then, I create an index to that table. This is needed for calling matches function. Here is the syntax :
    create index queryx on queries(query_string)
    indextype is ctxsys.ctxrule;
    then, I noticed that the result on DR$QUERYX$I table as follows :
    LARRY 0 2 2 1 (BLOB)
    MARKET 0 4 4 1 (BLOB) {MARKET} {SHARE}
    ORACLE 0 1 1 1 (BLOB)
    ORACLE 0 3 3 1 (BLOB) {TEXT}
    ELLISON 0 2 2 1 (BLOB)
    What I want to ask is why doesn't the words 'share' and 'text' appear in the DR$QUERYX$ table?
    When we use matches function, it then search on the index result and consequently it wion't find the 'share' word. so when for example I do query like this :
    select query_id from queries where matches(query_string,' It only share ten percent of all products sold')>0
    it will give 0 result since the no word in ' It only share ten percent of all products sold' was in index table. But actually it could possibly be categorized as the 4 category which rules is 'market share'
    I tried this in a larger set of data and get same result.
    Here is my generated rules from my document collection :
    1 {REQUIREMENTS} & {ELICITATION}
    1 {REQUIREMENTS} ~ {ELICITATION} & {ACTOR}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} & {FURPS}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} & {PROC}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} ~ {PROC} & {SPEED}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} ~ {PROC} ~ {SPEED} & {DOCUME}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} ~ {PROC} ~ {SPEED} ~ {DOCUME} & {PLACED}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} ~ {PROC} ~ {SPEED} ~ {DOCUME} ~ {PLACED} & {UNNECESSARY}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} ~ {PROC} ~ {SPEED} ~ {DOCUME} ~ {PLACED} ~ {UNNECESSARY} & {MISUSE}
    1 {INTERPRETATION} ~ {REQUIREMENTS}
    2 {DESIGN} & {REPRESENTATION}
    2 {DESIGN} ~ {REPRESENTATION} & {MAY} & {FOUNDATI} & {OCTOBER}
    2 {DESIGN} ~ {REPRESENTATION} & {MAY} & {FOUNDATI} ~ {OCTOBER} & {PROCEDURAL}
    2 {DESIGN} ~ {REPRESENTATION} & {MAY} & {FOUNDATI} ~ {OCTOBER} ~ {PROCEDURAL} & {STRICT}
    2 {DESIGN} ~ {REPRESENTATION} & {MAY} & {FOUNDATI} ~ {OCTOBER} ~ {PROCEDURAL} ~ {STRICT} & {GRASP}
    2 {DESIGN} ~ {REPRESENTATION} & {MAY} & {FOUNDATI} ~ {OCTOBER} ~ {PROCEDURAL} ~ {STRICT} ~ {GRASP} & {MANY} & {LAYER}
    2 {DESIGN} ~ {REPRESENTATION} ~ {MAY}
    3 {PM} & {TESTING} & {ATTRIBUTI}
    And this is the index table result with ctxrule :
    (only the token_text column shown)
    PM
    DESIGN
    DESIGN
    DESIGN
    DESIGN
    DESIGN
    DESIGN
    DESIGN
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    INTERPRETATION
    so when I try to classify a document with the word ouline inside it, it should produce category 1 (based on the rules) but since there are no word 'outline' in index tabel, the matches will return 0 means that the document is not classifiedto any category. I don't understand why it happen. Anybody knows about this? I would really appreciate any help.
    Thank you very much.

    Hm, I see. It do make sense. so nice to know.
    But then in the second example I gift where I used larger table, as shown below :
    Here is my generated rules from my document collection :
    1 {REQUIREMENTS} & {ELICITATION}
    1 {REQUIREMENTS} ~ {ELICITATION} & {ACTOR}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} & {FURPS}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} & {PROC}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} ~ {PROC} & {SPEED}
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE} ~ {PROC} ~ {SPEED} & {DOCUME}
    1 {INTERPRETATION} ~ {REQUIREMENTS}
    2 {DESIGN} & {REPRESENTATION}
    2 {DESIGN} ~ {REPRESENTATION} & {MAY} & {FOUNDATI} & {OCTOBER}
    2 {DESIGN} ~ {REPRESENTATION} & {MAY} & {FOUNDATI} ~ {OCTOBER} & {PROCEDURAL}
    2 {DESIGN} ~ {REPRESENTATION} & {MAY} & {FOUNDATI} ~ {OCTOBER} ~ {PROCEDURAL} & {STRICT}
    2 {DESIGN} ~ {REPRESENTATION} ~ {MAY}
    3 {PM} & {TESTING} & {ATTRIBUTI}
    As far as I know, the sign ' ~ ' means 'OR' and '&' means 'and' . So based on the 4th line in my table :
    1 {REQUIREMENTS} ~ {ELICITATION} ~ {ACTOR} ~ {FURPS} ~ {OUTLINE}
    it can be concluded that if any of the words stated there been queried, so the category '1' will appear as a result. But then before we can use 'matches' to query it, we need ti create index for the rules table . I did it and the result were :
    (only the token_text column shown)
    PM
    DESIGN
    DESIGN
    DESIGN
    DESIGN
    DESIGN
    DESIGN
    DESIGN
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    REQUIREMENTS
    INTERPRETATION
    there were no words other than PM, DESIGN< REQUIREMENTS and INTERPRETATION. Why the words REQUIREMENTS, ELICITATION, ACTOR, FURPS, OUTLINE don't appear in the index result?

  • Query of Queries (QofQ) Escaped Character Problem

    Hello All,
    I'm trying to run a query or queires (QofQ) and I'm doing a
    LIKE comparison that looks for bracket characters ([ ]) within a
    string, however ColdFusion is ignoring the brackets. How can I
    escape the bracket character? So far I have only been able to
    escape the percent sign based on the ColdFusion Live Docs. The
    error message I get when I run the query below is:
    Invalid Escape Sequence. Valid sequence pairs for this escape
    character are: "\%", or "\_".
    Here is the query:
    <cfquery dbtype="query" name="getLogs">
    SELECT *
    FROM GetLogs
    WHERE Description LIKE '%\[User:#UserID#\]%' ESCAPE '\'
    </cfquery>
    Thanks for your help!

    You are correct. If you leave the brackets in the LIKE
    statement, it will return results as if the brackets weren't there
    at all.
    Perhaps I need to figure out the ASCII character value of the
    bracket and include it that way i.e. #Char(?)# where the question
    mark would be the numerical value of that character.
    My temporary solution has been to leave off the starting
    bracket:
    <cfquery dbtype="query" name="getLogs">
    SELECT *
    FROM GetLogs
    WHERE Description LIKE '%user:#UserID#]%'
    </cfquery>
    This has (so far) returned the results i'm looking for
    although its not as 100% accurate without that beginning [ in the
    LIKE statement.

Maybe you are looking for

  • How to retry provisioning for pending values ?

    Hi, Our environment is IDM 7.2 SP7. And we have couple of users whose master privilege (PRIV:ADLDS:ONLY) is in pending state for quite a long time. I could filter those entries using mcExecState=512 in idmv_link_ext. It looks to me the reason for pen

  • Wide gamut or a standard gamut LCD

    I'm looking to buy a monitor for editing hd footage on a mac pro using cs 5.5. Should I get a standard or wide gamut display? Any recommendation would be appreciated. ty

  • ChaRM Copy Control for Ibase component

    Hi Team, I have created ZDCR which is copy of SDCR. And i have created ZDHF which is copy of SDHF. I have created the ZDHF as a subsequent document from ZDCR. While ZDHF is created, the Ibase component is not getting copied from ZDCR. How to copy the

  • 2Wire Router Issues - How to Turn off Security

    There appears to be an ongoing issue with MacBook wireless and the 2Wire routers (via AT&T/SBC). My wireless was working fine until I downloaded the recent Apple updates. I saw one fix for this posted here: http://discussions.apple.com/thread.jspa?th

  • Any fix for X-FI screech of death? *sound clip included for downlo

    http://members.cox.net/arfett/lamexfi.wav You can listen to it for yourself. Happens in certain games like conflict global storm if you turn the music all the way down. That clip happens to be from FEAR Extraction Point in which it happens throughout