SELECT * Not Returning Any Rows, But SELECT COL_NAME Does!

Jul 20, 2005

I have a table which is returning inconsistent results when I query
it!

In query analyzer:

If I do "SELECT * FROM TABLE_NAME" I get no rows returned.

If I do "SELECT COL1, COL2 FROM TABLE_NAME" I get 4 rows returned.

In Enterprise manager:

If I do "return all rows" I get 4 rows returned, and the SQL is listed
as being "SELECT * FROM dbo.TABLE_NAME".

I've tried adding the "dbo." before my table name in QA, but it seems
to make no difference.

I'm using SQL Server 2000, which is apparently 8.00534.

Can anyone help me, or give me ideas about what to check?

Thanks,

Rowland.

View 9 Replies


ADVERTISEMENT

SQL Server 2014 :: Select Statement Returning Too Many Rows For Backup Start Date

Jun 3, 2015

Here's my statement below. What I'm trying to get is joining the name column in master.sys.databases with a sub query for the database name, file location and backup start date from the MSDB database. The reason for this, if a new database has never been backed up, It should be returning as a NULL value, which is my goal. However, I'm getting multiple results for the backups.

select CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server,a.name,File_Location=b.physical_device_name,backup_start_date=max(backup_start_date)
from master.sys.databases a
left join(select c.database_name,backup_start_date=max(backup_start_date),b.physical_device_name
from msdb.dbo.backupmediafamily b join msdb.dbo.backupset c on c.media_set_id=c.backup_set_id
where c.type='D'

[Code] .....

View 8 Replies View Related

Select DISTINCT On Multiple Columns Is Not Returning Distinct Rows?

Jul 6, 2007

Hi, I have the following script segment which is failing:

CREATE TABLE #LatLong (Latitude DECIMAL, Longitude DECIMAL, PRIMARY KEY (Latitude, Longitude))

INSERT INTO #LatLong SELECT DISTINCT Latitude, Longitude FROM RGCcache



When I run it I get the following error: "Violation of PRIMARY KEY constraint 'PK__#LatLong__________7CE3D9D4'. Cannot insert duplicate key in object 'dbo.#LatLong'."



Im not sure how this is failing as when I try creating another table with 2 decimal columns and repeated values, select distinct only returns distinct pairs of values.

The failure may be related to the fact that RGCcache has about 10 million rows, but I can't see why.

Any ideas?

View 2 Replies View Related

Select Query Returning More Than One Value

Jul 6, 2007

Hi,
 My Select query returing the one column:
Options
1
2
3
Form this Options column I have to check the Checkbox1, checkbox2, checkbox3 out of total 6 checkboxes in asp.net form. I am getting the Options column from database.
How to store that resultset.
Thanks in advance.

View 2 Replies View Related

SQLRowCount() Returning -1 For SELECT Statement

Nov 13, 2007

Hi friends,
I am facing problem with SQLRowCount() function which is returning -1 when I tried to fetch records greater than 99 from my data file. if the data file contains total of 99 records then the above function is returning its second parameter value nRowCount as 99 but if dat file contains 100 records then it is returning nRowCount as -1
Please tell me whether it is a driver specic error or some thing else. I am using a ODBC driver for a database called MYOB.

Below is the piece of code that I used for fetching records.


if (SQLExecDirect(m_StmtHandle, (PUCHAR)sExecuteStatement.c_str(), SQL_NTS) != SQL_SUCCESS) return false;

if (SQLNumResultCols(m_StmtHandle,(SQLSMALLINT *) &nColumnCount) != SQL_SUCCESS) return false;

if (SQLRowCount(m_StmtHandle,&nRowCount) != SQL_SUCCESS) return false;

The string 'sExecuteStatement' in SQLExecDirect() function above is carrying a Select query that fetch 100 records.

Its strange that the function fails to return exact row count for 100 records, but it is working fine with 99 records.

I ma not using any kind of array with size of 99 or 100 in my code.

What I want to know is whether I can use SQLRowCount() with SELECT statement, If not what is the alternative.

Pleasee help me with a piece of code if you can.

Ishwar B.G

View 1 Replies View Related

SQLRowCount() Returning -1 When Used With SELECT Statement.

Nov 13, 2007

Hi friends,
I am facing problem with SQLRowCount() function which is returning -1 when I tried to fetch records greater than 99 from my data file. if the data file contains total of 99 records then the above function is returning its second parameter value nRowCount as 99 but if dat file contains 100 records then it is returning nRowCount as -1
Please tell me whether it is a driver specic error or some thing else. I am using a ODBC driver for a database called MYOB.

Below is the piece of code that I used for fetching records.


if (SQLExecDirect(m_StmtHandle, (PUCHAR)sExecuteStatement.c_str(), SQL_NTS) != SQL_SUCCESS) return false;

if (SQLNumResultCols(m_StmtHandle,(SQLSMALLINT *) &nColumnCount) != SQL_SUCCESS) return false;

if (SQLRowCount(m_StmtHandle,&nRowCount) != SQL_SUCCESS) return false;

The string 'sExecuteStatement' in SQLExecDirect() function above is carrying a Select query.

Its an unpredictable error because the function fails to return exact row count for 100 records, but it is working fine with 99 records.

I am not using any kind of array with size of 99 or 100 in my code.

What I want to know is:
1. Can I use SQLRowCount() with SELECT statement, If not what is the alternative.
2. Is this a driver specific error?.
3. Can I use SQL_DIAG_ROW_COUNT instead of SQLRowCount? If Yes, How to use it?.

Your help will be greatly appriciated if you give me a piece of code for this issue.

View 1 Replies View Related

Sql SELECT Returning NULL On DateTime Field

Aug 8, 2006

Hi there ;
This Problem is goin to make me crazy!
I've got a table with couple of fields, 2 of them are DateTime, in Sql Express 05 .
I used asp.net 2.0 to insert datetime values, directly,  using sth like DateTime.Now.ToString() .
i use 2 selects as follows :
1)select * from X where  Date1='8/9/2006 11:17:41 AM'
2)select * from X where  Date2='8/9/2006 11:17:41 AM'
#1 is OK, but the second one returns a row with all columns set to NULL .
(X is the name of the table)
Thanks in advance

View 6 Replies View Related

SELECT Statement Returning Nulls Unexpectedtly

Jun 14, 2008

All- Please assist: In this SELECT statement:
 1 SELECT person_id, (last + ', ' + first + ' on ' + CASE f.address_1 WHEN NULL THEN 'none' ELSE f.address_1 END) as last_first_address
2 FROM person
3
4 LEFT JOIN family f
5 ON person.family_id = f.family_id

I'm finding that the compound column last_first_address returns <null> when f.address_1 is null, even though it seems like it should return the string "none" per my CASE statement. If f.address_1 is not NULL, then it the statement works as expected. Please advise as to how I can fix the statement so that "none" is returned as the final string in last_fist_address if f.address_1 is null.
Note: I tried removing the parens. No effect on result. 
Thanks!
-Kurt
 

View 2 Replies View Related

Xquery - Select Not Returning All Attributes / Values

Jan 29, 2013

I have a table:

Code:
CREATE TABLE [dbo].[XmlTable](
[XmlId] [int] IDENTITY(1,1) NOT NULL,
[XmlDocument] [xml] NOT NULL,
CONSTRAINT [PK_XmlTable] PRIMARY KEY CLUSTERED

[Code] .....

With a schema structure:

Code:
<dev:Doc xmlns:dev="http://www.w3.org/2001/XMLSchema" SchemaVersion="0.1" Settings="Testing" Title="Ordering">
<dev:Base RevisionNumber="0" Baseid="34433" />
<dev:Rev Time="2013-01-21T15:08:00">
<dev:Person Name="Me" Systemid="54654" />
</dev:Rev>

[code]....

I am trying to return the id, number, name, and location of the visitors

Something like:

Code:
RevNumber Function Id Number Visitor Location Sender
========= =========== ======== ======= ======== ======
0 A1 1 Dev01 STLRF FGY(14A)
0 A1 1 Dev02 STLRF FGY(14A)
0 A1 1 Dev03 FGRTY FGY(14A)
0 A2 1 GHFF NULL W33R
0 A2 2 UDT NULL RJ4

Here is the table insert

Code:
INSERT INTO XmlTable(XMLDocument)
SELECT * FROM OPENROWSET(
BULK 'C:Users123DesktopPractice.xml',
SINGLE_BLOB) AS x;

I Have gotten a little further, but the number is not showing for A2 and the Sender, visitor is showing null.

Code:
;WITH XMLNAMESPACES ( 'http://www.w3.org/2001/XMLSchema' as dev )
SELECT
Document.value('@Title' , 'NVARCHAR(MAX)') Title,
Functions.value('@Id', 'NVARCHAR(MAX)') Functions,
A1.value('@Number', 'INT') Number,

[code]....

Results I am getting that are not all correct:

Code:
Title Functions Number VisitorName Location Sender
======== ========= ====== =========== ======== ======
Ordering A1 1 Dev01 STLRF NULL
Ordering A1 1 Dev02 STLRF NULL
Ordering A1 1 Dev03 FGRTY NULL
Ordering A2 NULL NULL NULL NULL

Not I changed Rev to Title

View 1 Replies View Related

T-SQL (SS2K8) :: Select Asterisk Not Returning All Columns In UDF

May 13, 2015

I have a UDF with a select * that works fine in one region (DEV) but not another (QC). It's not returning the last 2 columns from the table in QC.I looked at the UDF and it does a fairly simple select:

select a.*
from myTable A

The table is the same in both regions and I did a sp_help on the table to ensure these 2 columns are listed. They are. Also, executing a select * in a query windows does return the final 2 columns from the table in QC. The issue resides in the QC version of the UDF only.

The UDF has already been updated to retrieve all columns by name but I'm curious why this would happen. For some reason I'd just like to know and in case it happens again.

View 5 Replies View Related

SQL 2012 :: Select Top 100 - A Record Is Not Returning From Database

Aug 24, 2015

I have a strange situation with an select. I've noticed that when I select top 100, a record is not returning from the database, but when doing top 101 the record appears on position 41.

The query is like this:

select top 100 GroupId, count(HouseId)
from House h
group by h.GroupId
order by max([DateCreated]) desc

From all discussions about top 100 vs top 101 I've noticed that everybody is saying that top 101 is using another algorithm and we can have a speed problem, but my problem is not about this. With top 100 I'm missing a record that should appear at index 41.

View 9 Replies View Related

Select Returning Nbsp Instead Of An Empty String

May 15, 2008


I am using a SQLDataSource with the following Select query. If the "spouse" values are not in the database, I get the HTML non-breaking-space character back, rather than an empty string.


SelectCommand="select applicant_id, (applicant_last_name + ', ' + applicant_first_name) as applicant_name, CONVERT(varchar(10), applicant_dob, 101) as applicant_dob, applicant_ssn, (spouse_last + ', ' + spouse_first) as spouse_name, CONVERT(varchar(10), spouse_dob, 101) as spouse_dob, spouse_ssn from applicant where applicant_last_name like '%'+@last_name+'%' order by applicant_last_name"



Here is the relevant code-behind:


TextBox tb = (TextBox)formView.FindControl("SpouseName");

tb.Text = e.Item.Cells[4].Text;

DatePicker dp = (DatePicker)formView.FindControl("SpouseDateOfBirth");

if (e.Item.Cells[5].Text.Length > 0)

{

try // this is a try/catch because nbsp is not parsed as a date

{

dp.DateValue = DateTime.Parse(e.Item.Cells[5].Text);

}

catch

{

dp.txtDate.Text = "";

}

}

tb = (TextBox)formView.FindControl("SpouseSocialSecurityNumber");

tb.Text = e.Item.Cells.Text;



Thoughts?

Todd

View 4 Replies View Related

SqlDataSource And SSMSE Returning Different Results For Same SELECT Command

Oct 2, 2007

Hi,
Hope you guys won't mind this rather newbie question.  I'm writing a simple blog page for my website and have created a SqlDataSource which queries the database for a list of blog post titles (from the web.Blog table) and the number of comments (from the web.BlogComments table).  The SqlDataSource control is:
<asp:SqlDataSource ID="sourceBlogArticles" ProviderName="System.Data.SqlClient" connectionString="<%$ ConnectionStrings:myDatabase %>" runat="server" SelectCommand="SELECT gb.blogID, gb.title, gb.description, gb.tags, gb.dateAdded, COUNT(gbc.blogID) AS noOfComments FROM web.Blog gb LEFT OUTER JOIN web.BlogComments gbc ON gb.blogID = gbc.blogID GROUP BY gb.blogID, gb.title, gb.description, gb.tags, gb.dateAdded ORDER BY gb.dateAdded"></asp:SqlDataSource>
This works perfectly well if each blog entry in the web.Blog table has associated comments in the web.BlogComments table.  However, if there are no comments yet defined in the web.BlogComments table for that blogID then no row is returned in ASP.Net (as checked with a GridView control or similar linked to the data source to view what I get)
 HOWEVER, I think the SELECT command IS correct: if I use the select command as a query in SQL Server Managment Studio Express, I do get the rows returned, with 0 for the number of comments which is what I would expect for that query:
blogID, title, description, tags, dateAdded, noOfComments
1, title 1, description for title 1, tag1, 2007-09-27 06:49:03.810, 32, title 2, description for title 2, tag2, 2007-09-27 06:49:37.513, 03, title 3, description for title3, tag3, 2007-10-02 18:21:30.467, 0
Can anyone help?  The result from the SSMSE query is what I want, yet when I use the very same SELECT statement in my SqlDataSource I don't get any rows returned if the BlogComment count is zero (in the above example I get only the first row).  Many thanks for any suggestions!

View 6 Replies View Related

SELECT * View Returning Wrong Column Data

Oct 16, 2007

SQL 2005 9.00.3402.00 (x64) As Above really when I select * OR select a single column from the view the wrong column data is returned. in SQL Management Studio when I expand the Columns of the view it reflects the old table structure not the new table structure. I can easily fix by compiling the view again but this would mean I would have to recompile all referencing views when I make a change to table structures. I've tried various DBCC Clean Buffers & drop cache with no effect. Is there a command to recompile all views & poss stored procs in a database. Any help or explanation would be appreciated GW

View 12 Replies View Related

SELECT Returning Multiple Values In A Stored Proc

Jul 20, 2005

HiI'm not sure what the best approach for this is:I have a stored procedure which I would like to use to return severaloutput values instead of returning a recordset.CREATE PROCEDURE Test (@param1 int, @param2 int OUTPUT, @param3 intOUTPUT) ASSELECT field2, field3 FROM Table WHERE field1 = @param1I would like to return @param2 as field2 and @param3 as field3How do I do this without using SELECT multiple times?THanks in advanceSam

View 6 Replies View Related

Select Script Returning Different Results When Used In A Stored Procedure.

Nov 20, 2007



I have a script with a number of different Left Joins. When I run it in Query Analyzer the Left Join works as a normal join and suppresses some rows. However when the same code is used in a stored procedure the correct results are produced when the stored procedure is executed.
Can anyone tell me what is causing this?


SELECT USR.ROLEUSER
,PER.NAME
,EMP.PAYGROUP
,USR.ROLENAME
,OPR.EMPLID
,OPR.OPRDEFNDESC
,OPR.ACCTLOCK
,OPR.ROWSECCLASS
,EMP.JOBCODE
,JCD.DESCR
,EMP.DEPTID
,EMP.DEPTNAME


FROM PSROLEUSER USR
JOIN
PSOPRDEFN OPR
ON
USR.ROLEUSER = OPR.OPRID

LEFT OUTER JOIN
PS_PERSONAL_DATA PER
ON
OPR.EMPLID = PER.EMPLID

LEFT OUTER JOIN
PS_EMPLOYEES EMP
ON
OPR.EMPLID = EMP.EMPLID


LEFT OUTER JOIN
PS_JOBCODE_TBL JCD
ON
JCD.SETID = 'RBLTT'
AND EMP.JOBCODE = JCD.JOBCODE
AND JCD.EFFDT =
(SELECT MAX(EFFDT)
FROM PS_JOBCODE_TBL
WHERE JCD.SETID = SETID
AND JCD.JOBCODE = JOBCODE
AND EFFDT <= GETDATE())

WHERE OPR.ACCTLOCK = 0
AND USR.ROLENAME = 'RBL MANAGER'

AND EMP.PAYGROUP NOT IN ('RBA', 'RMA')

View 2 Replies View Related

Returning And Reading Multiple Select Statements From One Stored Procedure

Dec 3, 2006

Hey Guys. I’m having a little trouble and was wondering if you could help me out. I’m trying to create a custom paging control, so I create a stored procedure that returns the appropriate records as well as the total amount of records. And that works fine. What I’m having problems with is reading the data from the second select statement within the code. Anyone have any idea on how to do this? Also.. how can I check how many tables were returned?
Here's my code. I'm trying to keep it very generic so I can send it any sql statement:public DataTable connect(string sql)
{
DataTable dt = new DataTable();

SqlConnection SqlCon = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["MyDB"].ToString());
SqlDataAdapter SqlCmd = new SqlDataAdapter(sql, SqlCon);
System.Data.DataSet ds = new System.Data.DataSet();
SqlCmd.Fill(ds);

dt = ds.Tables[0];

//Here's where I don't know how to access the second select statement

return dt;
}  Here's my stored procedure:
 ALTER PROCEDURE dbo.MyStoredProcedure
(
@Page int,
@AmountPerPage int,
@TotalRecords int output
)

AS


WITH MyTable AS
(

Select *, ROW_NUMBER() OVER(ORDER BY ID Desc) as RowNum
From Table
where Deleted <> 1
)


select * from MyTable
WHERE RowNum > (((@Page-1)*@AmountPerPage)) and RowNum < ((@Page*@AmountPerPage)+1);

Select @TotalRecords = COUNT(*)
from Table
where Deleted <> 1
RETURN

Thanks

View 3 Replies View Related

T-SQL (SS2K8) :: Prevent SELECT Query From Returning Results Using LOCKS

Dec 2, 2014

I am trying to find a way to lock rows of data used in a SELECT query from being read by another SELECT query.

I could do a "begin tran - select - update - rollback" sequence but was wondering if there is a cleaner way to do this??

Tried UPDLOCK, ROWLOCK, TABLOCK, HOLDLOCK in multiple variations but none seem to block the select.

View 9 Replies View Related

Transact SQL :: Returning Multiple Values From Column In Select Statement?

Nov 26, 2015

I am writing a query and have the bulk of it already written. 

I am looking at a table that contains customer orders. There is a column named Customer_Order.Status Available values for this column is R, F, H, and C.

I'd like for my query to return all lines that have the value R, F, H.

My where clause is written like this 

WHERE CUSTOMER_ORDER.SITE_ID = 'XXX' AND CUSTOMER_ORDER.STATUS = ('R','H','F')

I know I'm missing something....

View 3 Replies View Related

Select Distinct Rows From Duplicate Rows....

Nov 28, 2007

Dear Gurus,I have table with following entriesTable name = CustomerName Weight------------ -----------Sanjeev 85Sanjeev 75Rajeev 80Rajeev 45Sandy 35Sandy 30Harry 15Harry 45I need a output as followName Weight------------ -----------Sanjeev 85Rajeev 80Sandy 30Harry 45ORName Weight------------ -----------Sanjeev 75Rajeev 45Sandy 35Harry 15i.e. only distinct Name should display with only one value of Weight.I tried with 'group by' on Name column but it shows me all rows.Could anyone help me for above.Thanking in Advance.RegardsSanjeevJoin Bytes!

View 4 Replies View Related

I Want To Select All Rows Between 10 And 20 .......

Feb 15, 2007

I want to select all rows between 10 and 20 from aview
 how can I do this?

View 3 Replies View Related

Select Last Rows

Feb 13, 2001

How can I SELECT the last rows inserted in a table?

View 2 Replies View Related

Select Rows By One For Each Value

Oct 12, 2004

Tell me please how to select from a table only rows with different value of one of fields (n_pr field). But I need also to select some other fields where the values can be different for one n_pr field's value and select only first value of them. For getting list of n_pr field's values I can use derived table of query with DISTINCT operator but I don't know how to join with other fields of the table to get only one row for each value of joinning field n_pr. I am using SQL Server 2000 and this DBMS can use TOP operator to select only one row but all the ways I've tryed affect all the query and I get one row at all instead of one for each n_pr field's value. Also I need in this query to connect one more table. So for efficiency it better to do it in one query or in one stored procedure that return a recodset as it needs.

View 1 Replies View Related

Select 2 Or More Rows With Same Id But..

Jun 24, 2008

I want to select rows that have been amended or deleted and want to use the amend date as the condition.all amended rows have a flag of 1 and deleted ones have a flag of 2
i.e
select * from table
where log_changed > '2008-06-23' and log_changed < '2008-06-24'
will display all the rows that were amanded on the 2008-6-23 and with a flag of 1 or 2

but i also want the query to return the original row that was amended and has a flag of 0.the original row has a null log_changed field.

the rows that must be returned must be the ones amended or deleted ones on a specific date but with the original ones as well.

any ideas please


In god we trust,everything else we test.

View 9 Replies View Related

Select Last 20 Rows

Jun 6, 2007

I am very new to db and sql. I have a populated table and would like to run a query that brings up the last 20 rows. Here is what I have now...do I need a WHERE statement?

SELECT

d.cache_diff AS $<scachediff>,
d.cache_name AS $<scachename>,
d.cache_type AS $<scachetype>,
d.cache_last_found AS $<cachelastfound>,
d.cache_id AS $<cache_view_link>,
d.cache_id AS $<log_find_link>

FROM geocaches d

View 5 Replies View Related

Select Rows With Like

Apr 28, 2008



Is it possible to write a stored procedure to select records that start with a passed string without using dynamic sql.
E.g.
SELECT EmpName FROM Employee WHERE EmpName LIKE 'John%'

How does write the above query as a stored procedure (not dynamic sql). The 'John' should be received as argument to the procedure.

View 3 Replies View Related

Select Rows Where Row Count &> 3

Jan 4, 2007

I have a view that I want to find all the rows that have a matching itemid and have more than 3 rows in them and group them by the itemid.
 I am not quite sure how to do this.
 Any ideas?
 ~mike~

View 5 Replies View Related

Select Distinct Rows

Mar 19, 2004

Hi,

I'm having a little bit of trouble trying to figure out how to do this query, right now I have:

SELECT I.AppItemId, P.ProductID, P.PartNum, P.Relist, I.AppUserId
FROM ProductsToRelist I join Products P on P.ProductID = I.AppSKU
WHERE P.Relist = 1 and I.AppStatus = 5 and Not I.AppItemId is Null

and it returns something like this:

AppItemId ProductID PartNum Relist AppUserId
2786 -32730 SELECT_OOS11
2787 -32729 SELECT12
2788 -32727 SELECT_OOS11
4269 -30987 SELECT_OOS12
1665 -30987 SELECT_OOS11
2433 -30987 SELECT_OOS11
4272 -30984 SELECT11
2436 -30984 SELECT11
2793 -32708 SELECT11


But I only it want it to return 1 record for each ProductID like so:

AppItemId ProductID PartNum Relist AppUserId
2786 -32730 SELECT_OOS11
2787 -32729 SELECT12
2788 -32727 SELECT_OOS11
4269 -30987 SELECT_OOS12
4272 -30984 SELECT11
2793 -32708 SELECT11


ProductID is the primary key for the Products table, and a product can be in the ProductsToRelist table many times but each row would have a unique AppItemId. I know that I need to use Distinct or a different kind of join, but I'm not sure which. How would you suggest to do this?

Thanks

View 4 Replies View Related

Select Distinct For Different Rows

Jun 5, 2006

I have the following tablecolumns:  [col1], [col2],[col3] and [NAME].I want to select the name column for each row where [col1]='07'.The problem is that there are several rows where [col1] contains '07' and also the name is the same. [col2] and [col3] contain different data for these double rows...however, I cant use the [col1] and [col2] values in my query because I dont know what values they contain beforehand.So now, when I execute my query and add the DISTINCT key I still get all the double rows!I hope this explains my problem, help is really appreciated...ow, btw: deleting the double rows is not an option....

View 4 Replies View Related

How To Select Specific Rows

Mar 21, 2001

Hello,


What is the command to select rows between RowNum25 and RowNum30 in a Sql table?

Aditya

View 1 Replies View Related

How Can I Select Only Entries With At Least 2 Rows?

Oct 15, 2004

heyas,
i wanna know how can i select only entries with at least 2 rows?
What i mean is that i want to make a select * from table1 where columnA = 'Something' order by columnB

but addicionally i want it to return only register that happen at least 2 times for columnB

thanks in advance!

View 2 Replies View Related

How To Select Specific Rows..

Dec 20, 2005

Hi Friends...

I have one table , suppose TableA which contains following columns..

I want to select records from this table where time difference is more than 2 min. (tec_insert_date) This means first record time and second one, then second one and third one..and so on..

How to select these records...pls give me some sql query...

thanks in advance


tec_number tec_insert_date tec_description
----------- ------------------------------------------------------ --------113909 2005-12-19 18:59:01.920 Description
113910 2005-12-19 18:59:02.043 Description
113911 2005-12-19 18:59:02.060 Description
113912 2005-12-19 18:59:02.060 Description
113913 2005-12-19 18:59:02.090 Description
113914 2005-12-19 18:59:02.090 Description
113915 2005-12-19 18:59:02.263 Description
113916 2005-12-19 18:59:02.437 Description
113917 2005-12-19 19:00:34.703 Description
113918 2005-12-19 19:00:34.720 Description
113919 2005-12-19 19:00:34.937 Description
113920 2005-12-19 19:00:35.607 Description
113921 2005-12-19 19:00:35.607 Description
113922 2005-12-19 19:00:35.840 Description
113923 2005-12-19 19:00:35.903 Description
113924 2005-12-19 19:00:36.200 Description
113925 2005-12-19 19:00:36.200 Description
113926 2005-12-19 19:00:36.217 Description
113927 2005-12-19 19:00:36.217 Description
113928 2005-12-19 19:00:36.217 Description
113929 2005-12-19 19:00:36.230 Description
113930 2005-12-19 19:00:36.230 Description
113931 2005-12-19 19:00:36.230 Description
113932 2005-12-19 19:00:36.230 Description
113933 2005-12-19 19:00:36.323 Description
113934 2005-12-19 19:00:36.450 Description
113935 2005-12-19 19:00:38.863 Description
113936 2005-12-19 19:00:38.943 Description
113937 2005-12-19 19:00:38.943 Description
113938 2005-12-19 19:00:39.100 Description
113939 2005-12-19 19:00:39.147 Description
113940 2005-12-19 19:00:39.300 Description
113941 2005-12-19 19:00:40.920 Description
113942 2005-12-19 19:01:23.363 Description
113943 2005-12-19 19:03:03.533 Description
113944 2005-12-19 19:03:08.197 Description
113945 2005-12-19 19:03:12.853 Description
113946 2005-12-19 19:03:14.087 Description
113947 2005-12-19 19:04:40.730 Description
113948 2005-12-19 19:04:44.843 Description
113949 2005-12-19 19:04:51.030 Description
113950 2005-12-19 19:04:56.313 Description
113951 2005-12-19 19:04:58.950 Description
113952 2005-12-19 19:09:19.950 Description
113953 2005-12-19 19:09:21.277 Description
113954 2005-12-19 19:09:21.340 Description
113955 2005-12-19 19:09:24.397 Description
113956 2005-12-19 19:09:35.660 Description
113957 2005-12-19 19:09:46.480 Description
113958 2005-12-19 19:09:47.790 Description
113959 2005-12-19 19:10:23.713 Description
113960 2005-12-19 19:10:23.980 Description
113961 2005-12-19 19:11:02.307 Description
113962 2005-12-19 19:11:52.040 Description
113963 2005-12-19 19:12:31.800 Description
113964 2005-12-19 19:12:31.940 Description
113965 2005-12-19 19:12:31.940 Description
113966 2005-12-19 19:13:10.500 Description
113967 2005-12-19 19:13:10.500 Description
113968 2005-12-19 19:13:50.697 Description
113969 2005-12-19 19:13:50.697 Description
113970 2005-12-19 19:13:50.743 Description
113971 2005-12-19 19:13:50.870 Description
113972 2005-12-19 19:13:50.883 Description
113973 2005-12-19 19:14:09.290 Description
113974 2005-12-19 19:14:47.680 Description
113975 2005-12-19 19:14:47.693 Description
113976 2005-12-19 19:14:48.630 Description
113977 2005-12-19 19:14:48.630 Description
113978 2005-12-19 19:14:49.127 Description
113979 2005-12-19 19:14:49.127 Description
113980 2005-12-19 19:14:49.160 Description
113981 2005-12-19 19:14:49.300 Description
113982 2005-12-19 19:14:49.313 Description
113983 2005-12-19 19:15:07.287 Description
113984 2005-12-19 19:15:07.783 Description
113985 2005-12-19 19:21:43.093 Description
113986 2005-12-19 19:22:01.920 Description
113987 2005-12-19 19:22:01.920 Description
113988 2005-12-19 19:22:20.780 Description
113989 2005-12-19 19:22:38.547 Description
113990 2005-12-19 19:22:38.547 Description
113991 2005-12-19 19:22:39.340 Description
113992 2005-12-19 19:22:39.340 Description
113993 2005-12-19 19:22:40.263 Description
113994 2005-12-19 19:22:41.010 Description
113995 2005-12-19 19:22:41.867 Description

View 3 Replies View Related

Select Duplicate Rows

Feb 11, 2004

I get a tabseparated textfile with data every friday. Faulty rows are to be returned to the source.

Double rows are considered a fault. How do I select all double rows?

I join the data later on with four columns so if these columns are alike the rows are considered identical even if other columns are not. Ie:

A, B, C, D, 12, 34, 48, 76
A, B, C, D, 23, 45, 56, 99

These two rows are considered alike since I join on A+B+C+D.

I'd like to select ALL double rows and insert them into a separate table that I can return to the source. Does anyone have an idea how to do this?

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved