具有内部联接问题的聚合

时间:2016-08-06 01:57:43

标签: sql sql-server

我在使用此功能来使用此AdventureWorks数据库示例时遇到问题。我正在尝试获得年度总收入超过500万的运输方法,但是当我取消注册员工数量和不同的员工数量时,两个总收入都相同。谁能给我一些帮助,所以我能理解我需要做什么?我已经尝试过CTE和over(),但聚合物当时并不同意我的看法。谢谢。

library(shiny)
ui <- fluidPage(
    h3("Normal text input"),
    textInput(inputId = "response1", label = "Type your Response Below"),

    h3("Styled textarea"),
    withTags(
      div(
        h5(b("Type your Response Below")), 
        textarea(id = "response2", 
                 class = "form-control shiny-bound-input",
                 style = "width: 300px; height: 34px")
      )
    ),

    br(),
    h3("Text from the styled textarea"),
    textOutput("out")
)

server<-function(input, output, session) {
  output$out <- renderText({
    input$response2
  })
}

shinyApp(ui = ui, server = server)

1 个答案:

答案 0 :(得分:0)

为什么这个小组为orderyear? (按s.Name分组,年份(P.OrderDate),p.VendorID)

SELECT 
  s.Name    AS 'ShippingMethod', 
  YEAR(P.OrderDate) AS 'OrderYear', 
  SUM(p.TotalDue)   AS 'Total Due', 
  AVG(p.TotalDue)   AS 'Average Total Due',
  COUNT(p.EmployeeID)  AS 'Number Of Employees',
  p.VendorID   AS 'Distinct Number of Employees'
FROM Purchasing.PurchaseOrderHeader AS P
 inner JOIN Purchasing.ShipMethod AS S
  ON  P.ShipMethodID = S.ShipMethodID --AND p.[Total Due]=p.[Average Total Due]

 group by s.Name, YEAR(P.OrderDate), p.VendorID