sql server - SQL LIMIT 1 DESC order -


I am trying to show only the best selling product at the work center, however, it keeps telling me that LIMIT 1 is incorrect sentence - configuration. I think that has helped find an answer here, so I decided to ask questions. Here working on my query

  SELECT WorkCenter.WorkCenterCode, Product.Name, SUM (Grahkordrlain. Quantity * CustomerOrderLine.ActualPrice) INNER Join productive as the workstation 'total sales. Workcentercode = product WorkCentcode INNER customers join the orderline but the product. Manufacturer = Customer Order Line Work seater by productive group. Workcontent code, product. No. By 'total sales limit Diissi 1    

Your query went a bit clearer:

  SELECT wc.WorkCenterCode, p.Name, SUM (col.Quantity * col.ActualPrice) "Total Sales" includes wc INNER workstation which wc.WorkCenterCode = productive p.WorkCenterCode INNER customer order line at p. Manufacturer = wc.WorkCenterCode by col.ProductID Group, p. No. "Total Sales" by the ORDER DESC Limit 1   

Note important changes in single quotes with double quotes. This is especially important for the order section, so the segment actually does something, instead of a continuous sorting instead of table aliens it is easy to read.

If you are using Visual Studio, then you should use top with limit : < pre> SELECT TOP 1 wc.WorkCenterCode, p.Name, SUM (col.Quantity * col.ActualPrice) as "net sales" workstation WC INNER wc.WorkCenterCode = p.WorkCenterCode INNER JOIN Join producer Customer orderline coon p. ProductID = Cole Product ID Group vs. Work Centrecode, p. No. "Total Sales" DESC by ORDER;

Edit:

For each row, for one line, enter the row_number () :

  SELECT WorkCenterCode, named "Total sales" fROM (SELECT wc.WorkCenterCode, p.Name, SUM (col.Quantity * col.ActualPrice) aS "total sales", row_number ( ) over (partition by SUM by wc.WorkCenterCode (col.Quantity * col.ActualPrice)) join the workstation productive wc INNER join as Sakannu in wc.WorkCenterCode = p.WorkCenterCode INNER P customer order line Manufacturer = col.prod "Total Sales" DESC by w.WorkCenterCode, p. Name) T WHERE SEQNUM = 1 ORDER by uctID Group;    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -