Solved

Sql 200 min value

Posted on 2014-12-23
2
144 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:steven
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

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:steven
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

623 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