Solved

Sql 200 min value

Posted on 2014-12-23
2
132 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 33

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server Remove all trailing commas 10 72
Getting the 3 middle digits 4 36
Testing connection to sql 7 58
sql query help 2 45
by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
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, f…

895 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

13 Experts available now in Live!

Get 1:1 Help Now