Click here to Skip to main content
15,438,171 members

Comments by kmoorevs (Top 16 by date)

kmoorevs 29-May-21 13:24pm View     CRLF
You should have read somewhere that sql top requires an order by clause. You don't mention which dbms this is against, but not all (such as mysql which uses a the limit keyword instead) will use the same syntax. Also it's not clear that you understand the use of parameters. It appears that you are trying to insert a variable where a parameter is expected. Either assign the variable to a parameter or better yet, simply concatenate the variable into the query...you don't even need to convert it to an int doing it that way.
kmoorevs 10-Nov-18 16:50pm View    
Sorry, I misread your queries originally. I was thrown off by the extra ) at the end of the outer query. It's not clear what you are trying to get as results. Top sales person per product type? (what about product type 555?)
kmoorevs 10-Nov-18 16:08pm View    
Second this answer, just wanted to add another benefit for using a database is the security. If you are really stuck on using files, consider xml...easy to load/manipulate/save and can be queried with linq.
kmoorevs 16-Jul-18 11:34am View    
Is that last date correct? (or should it be 2018) If the dates should be ordered ascending you can use subqueries to do what you want. If so, I can provide an example that works.
kmoorevs 30-Jun-18 17:55pm View     CRLF
Just to add, subqueries in the following form can solve many problems: Select Sum(sq.Sum_Sales) as Sales, Sum(sq.Sum_Purchases) as Purchases, sq.ItemCode From (Select Sum(A.Sales) as Sum_Sales, 0 as Sum_Purchases, A.ItemCode From tblSales A Group By A.ItemCode Union All Select 0 as Sum_Sales, Sum(B.Purchases) as Sum_Purchases, B.ItemCode From tblPurchases B Group By B.ItemCode) as sq