Solved

Sql 200 min value

Posted on 2014-12-23
2
131 Views
Last Modified: 2014-12-23
I am trying to return the min value of from a column.  The query is below...

INSERT INTO @ORIGCOUNT
    SELECT ITEM,LOC,WHSE,MIN(TAG_NUM)
      FROM  ENS_PHYINV
      WHERE SHEET_NUM IS NULL
      AND TSUMS IS NULL
         AND CNT_STAT = 'C'
         GROUP BY ITEM,LOC,WHSE,TAG_NUM

The results are not what I expected...below is what it returns...


R89C0001002      Stock      PA      500211
R89C0001002      stock      PA      500212

Why will it not return the first result set?
0
Comment
Question by:spoye
2 Comments
 
LVL 32

Accepted Solution

by:
ste5an earned 500 total points
ID: 40515146
Your statement does not return any rows, cause it's an INSERT statement. But when you refer to the SELECT clause not returning one row, then it's your GROUP BY clause. Remove TAG_NUM from it.
0
 

Author Closing Comment

by:spoye
ID: 40515233
Thank you for your help, i didn't explain it properly i ran the query and only wanted the min tag num one row inserted...  Thanks again for the help
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now