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


ADVERTISEMENT

Transact SQL :: Select Specific Values From All Rows Where Value Of A Specific Column Is (Active)

May 23, 2015

I need to select specific values from all rows where the value of a specific column is "Active"

This part works: SELECT LastName, FirstName, MiddleInit, ClientId FROM dbo.Client

But I want to add: WHERE StatusType = (Active) and how to do this.

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

Select A Specific Number Of Rows

Aug 25, 2005

I am working on a multi-page datagrid that pulls data from a database. The issue I am running into is the SQL select query. What I have is a table to 55 items. What I need to do is grab the first 35 of those items and bind the resulting DataReader to the grid, print the page, then grab the remaining 20 items, bind to the grid and print the page.

I can use "SELECT TOP 35 FROM Table" to get the first 35 items, but I don't know how to get the remaining 20 items. Is there a way to say something like "SELECT TOP 20 FROM Table" but specify only the rows that begin after row 35?

I tried doing this with an ArrayList but couldn't bind it to the DataGrid.

Any suggestions?

View 10 Replies View Related

Select Specific Number Of Rows

Mar 13, 2008

Hi,
Im using a select statement to query out the data from a table.

ex:- select * from tblperson

Now this select statement is returning me 500 rows

I want to see only the records between 100 - 200 out of these 500 rows..

Anyone help

View 13 Replies View Related

How To Select Specific 2 Rows Out Of A Huge Table

Jul 24, 2013

I have a very large table , and from that table I need just 2 records with column1 = 'A' and column1 = 'B' .

Here I don't think if I can not use OR or IN or Case operators because I need exactly 2 records not more.

View 6 Replies View Related

How To Select A Specific Value From Dataset To Fill A Specific Cell ?

Mar 27, 2007

Hi there !

Thanks for taking the time to read this thread.

I don't know whether anyone has this problem, but I am definitely not using the right keywords to search for a thread.

My situation is this...

I have a dataset that has values to fill cells to multiple tables in a report.
However, I only want to select specific data from the dataset to fill textboxes and others.
I cannot change the stored procedure, but the sample of the data is shown below:-


Row Stat Val
0 dtRpt1 02/01/2005
1 Value1 1
2 Value2 2000
3 dtMailSent 02/28/2005
4 Value3 0
5 Value4 5
6 Value5 658

I know it looks weird, but the row really represents which "row" or textbox is it to fill with the Val. The Stat Column is just a way to make sure that I am filling the right values.

so my new report would have multiple tables to denote different categories.
In my first table, I tried putting the cells as follows:-
(expressions are highlighted in italics and bold)

TextBox1 =IIF(Fields!Row.Value =0, Fields!Val.Value,"")

Table1
Column1
DetailRow1 =IIF(Fields!Row.Value =1, Fields!Val.Value,"")
DetailRow2 =IIF(Fields!Row.Value =2, Fields!Val.Value,"")


Table2
Column1
DetailRow1 =IIF(Fields!Row.Value =3, Fields!Val.Value,"")
DetailRow2 =IIF(Fields!Row.Value =4, Fields!Val.Value,"")
DetailRow3 =IIF(Fields!Row.Value =5, Fields!Val.Value,"")
DetailRow4 =IIF(Fields!Row.Value =6, Fields!Val.Value,"")


I only expect this report to print out one page holding the previous values.

However, it ended up printing like this

----------------------------------------------------------

Table1
Column1
DetailRow1 1
DetailRow2

Column1
DetailRow1
DetailRow2 2000


Table2
Column1
DetailRow1 02/28/2005
DetailRow2
DetailRow3
DetailRow4

Table2
Column1
DetailRow1
DetailRow2 0
DetailRow3
DetailRow4

Table2
Column1
DetailRow1
DetailRow2
DetailRow3 5
DetailRow4

Table2
Column1
DetailRow1
DetailRow2
DetailRow3
DetailRow4 658

------------------------------------------------------

I tried putting it into the headerrows instead of DetailRows, and it ended up printing the last value.
Is there anyway to do this ? print all the values out in one table ? I tried using textboxes, but I think I got my expression wrong.

Is this the correct expression ?

=IIF((Fields!Row.Value,"Dataset") =1, (Fields!Val.value, "Dataset"), "")

and it give me an error
The value expression for the textbox €˜textbox5€™ contains an error: [BC30455] Argument not specified for parameter 'FalsePart' of 'Public Function IIf(Expression As Boolean, TruePart As Object, FalsePart As Object) As Object'.

Appreciate any advice or suggestion for this scenario !

Thanks!

Bernard

View 3 Replies View Related

How To Get Specific Rows From Table

Aug 24, 2006

hi

i m using row count in order to get first 16 rows from a specific table...now i want to get rows from row no. 16 to 32 (or any no which i want)...can any one tell meee how can i query it using sql server 200





View 3 Replies View Related

Not Printing Specific Rows

Jul 12, 2007

Hello everybody





I'm workung on a report which will both function as a online report but also as a printed sheet. i've got a table which has to be sortable, so i made a user sort. however, to fit the report onto a page, i had to make a additional header row, which contains only the sorting arrows. now, i'd like this row not to apear on the printed out version, how would i do this?


Alternativly, would it be possible to not show the user sort icons (down- and upwards arrows), but to make the header fields clickable? This would solve my problem as well.


thanks for any advice

exmap

View 2 Replies View Related

Sum Function: Only On Specific Rows

Nov 16, 2006

Hi,

I have a table where I want to use the sum function, but only on the rows with a positive value.

Is there any way to do this?

View 5 Replies View Related

Rows Which Are Associated With Values Greater Than Specific Value

Jun 5, 2014

I am trying to select all the data which are not associated with values older than a specific value.. For example I have:

paola -- 2
paola -- 3
paola -- 10

jessica -- 3
jessica -- 12

james -- 3
james -- 2
james -- 5

I want to query only those names, that are associated with numbers greater than 3. So, for this example, the result would be only Jessica. the others should be discarded.

View 4 Replies View Related

Sql - Pulling Data From Specific Rows

Nov 12, 2006

I have a table, multiple columns, thousands of rows.

Six of the columns is the data that i need to work with...

col1, col2, col3, col4, col5, col6

col1 and col2 - go together - example. col1 = amount col2 = description
col3 and col4 - go together col3 = amount col4 description
col5 and col6 - go together col5 amount and 6 description

i need to pull search the table based on an auto number "id" and pull in the necessary two columns that correspond with a set value in the description.

example:

if col4 has "fee applied" in the description i need to pull the amount.

Please help...

Thank you in advance

View 3 Replies View Related

Counting Number Of Specific Rows In SQL

May 22, 2007

hi,

I would like to create a user defined SQL function which returns the number of rows which meets certain condition, and the average value of one of the culomns. I cannot find a code example for it. Please help.



Thanks,

Dror.

View 7 Replies View Related

Get Specific Rows From A Table (using Max And Group By)

Apr 8, 2008

Hi

I'm no expert at SQL, I can't figure out how to solve that problem.

The following statement:

SELECT TeamMemberId, max(MonthId) as MonthId
FROM Position
INNER JOIN [Month] m
INNER JOIN [Year] y ON m.YearId = y.Id AND (y.Id = @yearId OR y.Id < @yearId)
ON m.Id = Position.MonthId
GROUP BY TeamMemberId


Returns
TeamMemberId MonthId
1 14
6 20

which is exactly what I want: The greates MonthId for each TeamMember in a specific year.

But I need more data for this postition, like the PositionName.

But the statement:

SELECT TeamMemberId, max(MonthId) as MonthId, PositionName
FROM Position
INNER JOIN [Month] m
INNER JOIN [Year] y ON m.YearId = y.Id AND (y.Id = 2 OR y.Id < 2)
ON m.Id = Position.MonthId
GROUP BY TeamMemberId, PositionName

Returns
TeamMemberId MonthId PositionName
1 2 ***. d. Geschäftsführung
6 20 ***. d. Geschäftsführung
1 14 CEO
6 16 CEO

The red rows are the ones I wanna get.
How can I achieve that only the max. MonthId rows are returned, even when I need to select more columns?
Any help is much appreciated.


Regards,

Stefan

View 6 Replies View Related

How To Sum A Specific Number Of Rows In An Expression?

Apr 17, 2008

Hi All
Lets say i have that table:



Month Sales
1 30
1 10
1 10
1 20
2 30
2 30
2 15
3 1


How can i get the sum of the sales where month=1?
I need to do it in the Expression of a text box

View 7 Replies View Related

T-SQL (SS2K8) :: Search Through Rows With Specific Values

Sep 16, 2015

I've a table that stores operationcode for each jobnumber. The jobnumber can have multiple operationcode. From the below DDL, I need to show all the jobs that have operation codes as 2001 and 2002. In the below DDL Jobnumber 80011 has both the operation codes 2001 and 2002 so this job will display on the report.

On the other hand Job 80021 only has operationcode 2001 and I do not want this job to show up on the report.

I need to show all the operationcodes for a job if it has operationcode 2001 and 2002.

USE tempdb;
GO
DECLARE @TEST_DATA TABLE
(
DT_ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED
, OperationCodeVARCHAR(10) NOT NULL
, EmployeeCode VARCHAR(10) NOT NULL

[Code] ....

View 9 Replies View Related

Selecting A Specific Numbered Range Of Rows.

Jul 26, 2006

Hello all, thanks in advance for any help you might be able to give.

I'm familiar with the Top command but I need something else to help in a project I'm working on.

I would like to select rows 1 through 100000 from a specific table in one query then 100001 through 200000 in a second query and 200001 through 300000 in a third and so on until I have gone through all rows. There happens to be 424000 in the table I'm working on.

Any help is appreciated.

View 12 Replies View Related

T-SQL (SS2K8) :: Find All Rows From All Tables In A DB For Specific Column?

Mar 28, 2014

I have a DB with some tables and, on certain tables, i've a column named "ID_COMPUTER".

I need to find all the rows where id_computer=<specific_value> from all the tables of my database, when column "ID_COMPUTER" exists.

Pseudo-code would be: select * from db.* where id_computer=<specific_value>

how to write this ?

View 2 Replies View Related

SQL 2012 :: How To Find Unique Rows Considering Only Specific Columns

Apr 18, 2014

write a query which retrieves only unique rows excluding some columns.

IdStatusmanager Team Comments Proj number Date
19391New XUnassigned One 3732.0 16-Apr-14
19392Can YCustomer Two 3732.0 17-Apr-14
19393Can YCustomer Two 3732.0 17-Apr-14
19394Can YCustomer One 3732.0 18-Apr-14
19395New YCustomer One 3732.0 19-Apr-14
19396New YCustomer One 3732.0 21-Apr-14
19397New ZCustomer One 3732.0 20-Apr-14

In the above table project number and id shouldn't be considered and I should get the unique rows considering rest of columns and sorted based on date. Expected result is

IdStatusmanager Team Comments Proj number Date
19391New XUnassigned One 3732.0 16-Apr-14
19392Can YCustomer Two 3732.0 17-Apr-14
19394Can YCustomer One 3732.0 18-Apr-14
19395New YCustomer One 3732.0 19-Apr-14
19397New ZCustomer One 3732.0 20-Apr-14
19396New YCustomer One 3732.0 21-Apr-14

View 4 Replies View Related

SQL Server 2014 :: Check If Two Rows Have A Different Value In A Specific Column

Sep 9, 2015

I have huge export files in a DB and i need to check if there are any datasets that have the same value in the first column, but a different in another one, via a query of course.

Like this:

ID IS NULL
1 1
2 1
3 0
1 0

The expected ID i get as a result of my query should be 1 in this case.

View 6 Replies View Related

Show Total Amount Of Rows In Specific Table

May 20, 2012

I need to show the total amount of rows in a specific table?

The query is as follows:

As part of the planning process to expand the database that supports Northwind operations, the IT manager would like to know how many rows are currently in specific tables so that he can conduct capacity planning.

The results needed include two columns, TableName( containing all the tables in the database and Rows, which contain the total amount of all the rows per table).

View 4 Replies View Related

Power Pivot :: Update Specific Rows In Table

May 21, 2015

I have a text file which I used as an initial load of data, containing a little over a million rows. I would like to produce a daily "update" file, which contains changes to existing rows, and creation of new rows. What is the best method of updating the existing table in power pivot?

View 2 Replies View Related

Power Pivot :: How To Count Rows Where A Specific Value Exist

May 20, 2015

This is primarily  a question for DAX/Power BI. I'm trying to figure out how to count rows for a particular column where only a specific value exist. For instance, I'm trying to count how many times a certain field contains a true value or false value across multiple columns. 

I found this formula here: [URL] ....

=CALCULATE(COUNTROWS('table'), ALLEXCEPT('table', 'table'[n_country]))

However, I'm not quite sure how to adapt it to count only rows where a value is equal to True, False, 17, "foobar", etc...

View 5 Replies View Related

How To Feed Specific Rows From Excel Spreadsheet To OLE DB Destination

Jan 2, 2008

Hi,

I am in a bit of a quandry. I have an Excel spreadsheet source, but I only want certain rows from the spreadsheet, which will be delineated by a header and footer row (Start and End). Here is my script thus far (see below).

My question is, what is the correct way to do this? I guess I am stuck on syntax. i.e.) Do I need to create an OUTPUT BUFFER?

Thanks

==============================

Sample data:
blah
Start
Frank 1234 1234 1234
Sue 2345 2345 2345
End
blah
blah

==============================


Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

Static Section As String


'Set sections

If Row.Name = "Start" Then


Section = "Start"

End If

If Row.Name = "End" Then


Section = "End"

End If


If Section = "Start" Then

'GRAB THESE ROWS AND SEND THROUGH THE PIPELINE
'IGNORE ALL OTHER ROWS!
'What syntax goes here?
'Output buffer?



End If


End Sub

View 9 Replies View Related

Select A Specific Row

Jun 12, 2003

I have a case where I need to randomly select two different serial numbers (a list of serial number are already in a table) and assign it to two variables. Or select a specific row from a list of results. Is there a direct way to do this?

e.g.
declare @var1 varchar(10), @var2 varchar(10)

select top 1 @var1=Serial from Table order by Serial
select top 1 @var2=Serial from Table where ServTag not in (@var1) order by Serial

select @var1, @var2

:confused:

View 2 Replies View Related

How Rows Get Deleted Auomatically In Sql Table After Specific Interval Of Time

May 17, 2008

hi there
i am using .net framework 1.1 with SQL 2000 .
i want the data in table to get deleted automatically after 30 days of inserting data.
so how do i achieve this?

View 4 Replies View Related

Retrieving Specific Page(number Of Rows) Form Table

Sep 27, 2005

hi,

i need SP that receive 2 integers ,@NUM_ROWS and @PAGE_NUMBER,
and return the rows in that page.
for example:

SP(4,2) will return 4 rows in page number 2 .

So if i have table with 9 rows i will get rows 5-8,
the first page is rows 1-4 the second page is 5-8 and the 3 page is row 9.

i have to assume that rows can be deleted form that table.
thanks

View 3 Replies View Related

SQL Server 2012 :: Evaluating Rows And Selecting Specific Records

Mar 18, 2015

I have a table with some examples below. I need to identify records where:

1. the person has 3 or more consecutive months ordered.
2. I then need to exclude the first and last month and capture only those Months in between.

PERSON ID MONTH ORDERED
JD12345 4
JD12345 7
JD12345 8 Note: JD12345 should be excluded entirely

[code]....

View 6 Replies View Related

Select With Or In A Specific Field

May 25, 2008

I've a select SELECT Field1, Field2, Field3 FROM Tablethe problem is that I can have filled Field1 OR Field2 ... I would like to create a new column in the result for see only the filled field  if Field1 is = null or  = ' ' I want to see Field2 if Field2 is = null or  = ' ' I want to see Field1

View 2 Replies View Related

[How Do I...?] SELECT From A Specific Partition?

Oct 26, 2006

If I have a table split up among partitions A, B, C, how do I select only from partition C?

~Le

View 1 Replies View Related

Select Max If Value Of Specific Field Is Y

May 15, 2014

I need to check if the latest record in a table for the current client, based on EFFECTIVE_DATE, has a value of 'Y' in the STATUS field. Sample records for client #19:

CLIENTEFFECTIVE_DATESTATUS
------ -------------- ------
19 08/13/2010Y
1901/10/2013N
1902/03/2014Y

If I run:
SELECT CLIENT, max(EFFECTIVE_DATE), STATUS
FROM FTABLE GROUP BY CLIENT, STATUS

I get the two latest records since STATUS is different:

CLIENTEFFECTIVE_DATESTATUS
------ -------------- ------
1901/10/2013N
1902/03/2014Y

I wrote the following and it works, but it may be causing 'Insufficient Disk Space' error from the database. Is there any way to write this query without temp table?

DECLARE @TEMPMAX

TABLE (CLIENT INT, EDATE DATE)
INSERT INTO @TEMPMAX (CLIENT, EDATE)
SELECT CLIENT_NO, max(EFFECTIVE_DATE)

[Code] ....

CLIENTEFFECTIVE_DATESTATUS
------ -------------- ------
1902/03/2014Y

View 3 Replies View Related

Select Specific Character

Dec 15, 2014

How to select specific character when you have a different length of characters. For example I have a columm where I have character ":". How to select only ":"?

View 2 Replies View Related

How To Select Specific Record.

Oct 24, 2007

Group_Code *****Station_nbr*****Beg_Eff_Date*****End_eff_date

00000002 D01G00733 1/1/2007 8/31/2007
00000002N D01G00733 4/1/2007 8/31/2007
00000002W D01G00733 1/1/2007 12/31/2007


For the report I just want to be able to pick up the first and the last line.

Using dbo.Station_group Table

Thank you for the help

View 14 Replies View Related







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