Numbering Rows In A Resultset

Nov 19, 2001

Hello all,

I'm trying to number rows in a resultset by a grouping.

e.g. if my data looks like this:

personname persondata
----------- -----------------
person1 data
person1 more data
person1 other data
person2 stuff
person2 more stuff
person2 even more stuff
person2 lots of stuff
person2 last bit of stuff
person3 info
person3 more info

I want it to return this, with x as a sub-numbered value (like an identity for each grouping):

x personname persondata
-- ----------- -----------------
1 person1 data
2 person1 more data
3 person1 other data
1 person2 stuff
2 person2 more stuff
3 person2 even more stuff
4 person2 lots of stuff
5 person2 last bit of stuff
1 person3 info
2 person3 more info

Any ideas?

Thanks,

Dan

View 2 Replies


ADVERTISEMENT

Numbering Rows In A Result Set

Nov 29, 2001

work_id Work_item_code

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

3 Sup

14 100001

5 100002

16 100003

8 IWSM

9 ES3000

10 AppDev

11 100004

I want to have a counter on this select like

work_id Work_item_code counter

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

3 Sup 1

14 100001 2

5 100002 3

16 100003 4

8 IWSM 5

9 ES3000 6

10 AppDev 7

11 100004 8

I can use rownum in Oracle, what do I do to get this in SQL server ?

Thanks Sonali

View 2 Replies View Related

Numbering Rows With A Twist

Jul 20, 2005

OK,Here is my challenge.If I have a query that produces the followingItemSold_OnA01-10-2004 8:03A01-11-2004 10:05A01-12-20041:37A01-14-20047:16B01-10-20049:37B01-12-2004 11:42B01-13-20049:37But I need it to produce this insteadItemSold_On InstanceA01-10-2004 8:031A01-11-2004 10:052A01-12-20041:373A01-14-20047:164B01-10-20049:371B01-12-2004 11:422B01-13-20049:373So basically I need it to chronologically number the rows, but I needthe count to start over when the item changes.

View 3 Replies View Related

Auto Increment --Numbering Rows

Sep 1, 2005

How can I issue a SQL statement to assign incrementing numbers starting from a particular row. For e.g.,

col1 col2
----- -----
aaa 123
... 345
xxx 001
yyy 002
zzz 003

I would like to have numbering in col2 to start where col1=XXX to ZZZ.

Thank you

View 1 Replies View Related

Getting Unique Rows From The Resultset

Nov 15, 2006

Hi,

I am trying to do a join which involves more than 3 tables. One is a parent table and the other two table have 1:n relationship with that parent table.

But duplicate records are being returned in the resultset. How do I eliminate duplicate records?

This is my query.

SELECT table1.* from table1 left outer join table2 on table1.id=table2.id
left outer join table3 on table1.id=table3.id

I tried doing DISTINCT here but with no success.

SQL with distinct clause.

SELECT distinct table1.id, table1.* from table1 left outer join table2 on table1.id=table2.id
left outer join table3 on table1.id=table3.id

This is the error I get:
The text data type cannot be selected as DISTINCT because it is not comparable

Please help.

View 4 Replies View Related

Resultset With Summary Rows

Feb 26, 2004

Hi,

I have problem with query/sp which need to return one resultset with strucure like:

summary row1
detail row1
detail row2
detail row3
summary row2
detail row4
detail row5
...

Tables:
T_HW (HW_ID INT, CatID INT, other cols (NVARCHARs, INTs, DATETIMEs, NTEXTs etc.)
T_Category (CatID INT, Manufact NVARCHAR (100), other cols)

The output I need is ( '|' means cols separator) :
Manufact1 | No of recs from HW for this Manufact | nulls ...
null | null | HW1 from Manufact1 details ...
null | null | HW2 from Manufact1 details ...
Manufact2 | No of recs from HW for this Manufact | nulls ...
null | null | HW3 from Manufact2 details ...
...

it needs to be one result recordset

Thx in advance,
MST78

View 4 Replies View Related

Removing Partially Duplicate Rows For Resultset ? Help Needed.

Feb 2, 2008

Hi, Please help me with an SQL Query that fetches all the records from the three tables but a unique record for each forum and topicid with the maximum lastpostdate. Please provide separate solutions for SqlServer2000/2005. 
I have four tables namely – Forums,Topics,Threads and Messages  in SQL Server2000 (scripts for table creation and insertion of test data given at the end). Now, I have formulated a query as below :- 
SELECT Forums.forumid AS ForumID,Topics.topicid AS TopicID,Topics.name AS TopicName,LastPosts.date as LastPostDate,LastPosts.author AS Author,
(select count(threadid) from Threads where Threads.topicid=Topics.topicid) as NoOfThreads
FROM Forums JOIN Topics ON Forums.forumid=Topics.forumid
LEFT OUTER JOIN
(
                 SELECT Topics.forumid,Threads.topicid,Messages.date,Messages.author FROM Topics
             INNER JOIN Threads ON Topics.topicid = Threads.topicid
                 INNER JOIN Messages ON Threads.threadid=Messages.threadid
             WHERE Messages.date=(SELECT MAX(date) FROM Messages WHERE Messages.threadid = Threads.threadid)
) as LastPosts
ON LastPosts.forumid = Topics.forumid AND LastPosts.topicid = Topics.topicid 
Whose result set is as below:- 




forumid
topicid
name
LastPostDate
author
NoOfThreads

1
1
Java Overall
2008-02-02 13:06:06.267
l@m.com
2

1
1
Java Overall
2008-01-27 14:46:41.000
c@b.com
2

1
2
JSP
NULL
NULL
0

1
3
EJB
NULL
NULL
0

1
4
Swings
2008-01-27 15:12:51.000
p@q.com
1

1
5
AWT
NULL
NULL
0

1
6
Web Services
NULL
NULL
0

1
7
JMS
NULL
NULL
0

1
8
XML,HTML
NULL
NULL
0

1
9
Javascript
NULL
NULL
0

2
10
Oracle
NULL
NULL
0

2
11
Sql Server
NULL
NULL
0

2
12
MySQL
NULL
NULL
0

3
13
CSS
NULL
NULL
0

3
14
FLASH/DHTLML
NULL
NULL
0

4
15
Best Practices
NULL
NULL
0

4
16
Longue
NULL
NULL
0

5
17
General
NULL
NULL

I want the result set as follows:- 




forumid
topicid
name
LastPostDate
author
NoOfThreads

1
1
Java Overall
2008-02-02 13:06:06.267
l@m.com
2

1
2
JSP
NULL
NULL
0

1
3
EJB
NULL
NULL
0

1
4
Swings
2008-01-27 15:12:51.000
p@q.com
1

1
5
AWT
NULL
NULL
0

1
6
Web Services
NULL
NULL
0

1
7
JMS
NULL
NULL
0

1
8
XML,HTML
NULL
NULL
0

1
9
Javascript
NULL
NULL
0

2
10
Oracle
NULL
NULL
0

2
11
Sql Server
NULL
NULL
0

2
12
MySQL
NULL
NULL
0

3
13
CSS
NULL
NULL
0

3
14
FLASH/DHTLML
NULL
NULL
0

4
15
Best Practices
NULL
NULL
0

4
16
Longue
NULL
NULL
0

5
17
General
NULL
NULL
0  I want all the rows from the Forums,Topics and Threads table and the row with the maximum date (the last post date of the message) from the Messages table as shown above. 
When I use the query by using only three tables namely Forums,Topics and Threads, I get the correct result. The query is as:- 
SELECT Topics.forumid AS ForumID,Forums.name AS ForumName,Topics.topicid as TopicID,Topics.name as TopicName,
LastPosts.author AS Author,LastPosts.lastpostdate AS LastPost,
(select count(threadid) from threads where Threads.topicid=Topics.topicid) as NoOfThreads
FROM Forums JOIN Topics ON Forums.forumid=Topics.forumid LEFT OUTER JOIN (
             SELECT Topics.forumid, Threads.topicid, Threads.lastpostdate, Threads.author FROM Threads
             INNER JOIN Topics ON Topics.topicid = Threads.topicid
             WHERE Threads.lastpostdate IN (SELECT MAX(lastpostdate) FROM threads WHERE Topics.topicid = Threads.topicid)
             ) AS LastPosts
             ON LastPosts.forumid = Topics.forumid AND LastPosts.topicid = Topics.topicid 
Whose result set is as:- 




ForumID
ForumName
TopicID
TopicName
Author
LastPost
NoOfThreads

1
Developers
1
Java Overall
x@y.com
2008-01-27 14:48:53.000
2

1
Developers
2
JSP
NULL
NULL
0

1
Developers
3
EJB
NULL
NULL
0

1
Developers
4
Swings
p@q.com
2008-01-27 15:12:51.000
1

1
Developers
5
AWT
NULL
NULL
0

1
Developers
6
Web Services
NULL
NULL
0

1
Developers
7
JMS
NULL
NULL
0

1
Developers
8
XML,HTML
NULL
NULL
0

1
Developers
9
Javascript
NULL
NULL
0

2
Database
10
Oracle
NULL
NULL
0

2
Database
11
Sql Server
NULL
NULL
0

2
Database
12
MySQL
NULL
NULL
0

3
Desginers
13
CSS
NULL
NULL
0

3
Desginers
14
FLASH/DHTLML
NULL
NULL
0

4
Architects
15
Best Practices
NULL
NULL
0

4
Architects
16
Longue
NULL
NULL
0

5
General
17
General
NULL
NULL
0  
The scripts for creating the tables and inserting test data is as follows in an already created database:- 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__Topics__forumid__35BCFE0A]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[Topics] DROP CONSTRAINT FK__Topics__forumid__35BCFE0A
GO 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__Threads__topicid__34C8D9D1]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[Threads] DROP CONSTRAINT FK__Threads__topicid__34C8D9D1
GO 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__Messages__thread__33D4B598]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[Messages] DROP CONSTRAINT FK__Messages__thread__33D4B598
GO 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Forums]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Forums]
GO 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Topics]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Topics]
GO 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Threads]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Threads]
GO 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Messages]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Messages]
GO 
CREATE TABLE [dbo].[Forums] (
            [forumid] [int] IDENTITY (1, 1) NOT NULL ,
            [name] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
            [description] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO 
CREATE TABLE [dbo].[Topics] (
            [topicid] [int] IDENTITY (1, 1) NOT NULL ,
            [forumid] [int] NULL ,
            [name] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
            [description] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO 
CREATE TABLE [dbo].[Threads] (
            [threadid] [int] IDENTITY (1, 1) NOT NULL ,
            [topicid] [int] NOT NULL ,
            [subject] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
            [replies] [int] NOT NULL ,
            [author] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
            [lastpostdate] [datetime] NULL
) ON [PRIMARY]
GO 
CREATE TABLE [dbo].[Messages] (
            [msgid] [int] IDENTITY (1, 1) NOT NULL ,
            [threadid] [int] NOT NULL ,
            [author] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
            [date] [datetime] NULL ,
            [message] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO 
ALTER TABLE [dbo].[Forums] ADD
             PRIMARY KEY  CLUSTERED
            (
                        [forumid]
            )  ON [PRIMARY]
GO 
ALTER TABLE [dbo].[Topics] ADD
             PRIMARY KEY  CLUSTERED
            (
                        [topicid]
            )  ON [PRIMARY]
GO 
ALTER TABLE [dbo].[Threads] ADD
             PRIMARY KEY  CLUSTERED
            (
                        [threadid]
            )  ON [PRIMARY]
GO 
ALTER TABLE [dbo].[Messages] ADD
             PRIMARY KEY  CLUSTERED
            (
                        [msgid]
            )  ON [PRIMARY]
GO 
ALTER TABLE [dbo].[Topics] ADD
             FOREIGN KEY
            (
                        [forumid]
            ) REFERENCES [dbo].[Forums] (
                        [forumid]
            )
GO 
ALTER TABLE [dbo].[Threads] ADD
             FOREIGN KEY
            (
                        [topicid]
            ) REFERENCES [dbo].[Topics] (
                        [topicid]
            )
GO 
ALTER TABLE [dbo].[Messages] ADD
             FOREIGN KEY
            (
                        [threadid]
            ) REFERENCES [dbo].[Threads] (
                        [threadid]
            )
GO  
------------------------------------------------------ 
insert into forums(name,description) values('Developers','Developers Forum');
insert into forums(name,description) values('Database','Database Forum');
insert into forums(name,description) values('Desginers','Designers Forum');
insert into forums(name,description) values('Architects','Architects Forum');
insert into forums(name,description) values('General','General Forum'); 
insert into topics(forumid,name,description) values(1,'Java Overall','Topic Java Overall');
insert into topics(forumid,name,description) values(1,'JSP','Topic JSP');
insert into topics(forumid,name,description) values(1,'EJB','Topic Enterprise Java Beans');
insert into topics(forumid,name,description) values(1,'Swings','Topic Swings');
insert into topics(forumid,name,description) values(1,'AWT','Topic AWT');
insert into topics(forumid,name,description) values(1,'Web Services','Topic Web Services');
insert into topics(forumid,name,description) values(1,'JMS','Topic JMS');
insert into topics(forumid,name,description) values(1,'XML,HTML','XML/HTML');
insert into topics(forumid,name,description) values(1,'Javascript','Javascript');
insert into topics(forumid,name,description) values(2,'Oracle','Topic Oracle');
insert into topics(forumid,name,description) values(2,'Sql Server','Sql Server');
insert into topics(forumid,name,description) values(2,'MySQL','Topic MySQL');
insert into topics(forumid,name,description) values(3,'CSS','Topic CSS');
insert into topics(forumid,name,description) values(3,'FLASH/DHTLML','Topic FLASH/DHTLML');
insert into topics(forumid,name,description) values(4,'Best Practices','Best Practices');
insert into topics(forumid,name,description) values(4,'Longue','Longue');
insert into topics(forumid,name,description) values(5,'General','General Discussion'); 
insert into threads(topicid,subject,replies,author,lastpostdate) values (1,'About Java Tutorial',2,'a@b.com','1/27/2008 02:44:29 PM');
insert into threads(topicid,subject,replies,author,lastpostdate) values (1,'Java Basics',0,'x@y.com','1/27/2008 02:48:53 PM');
insert into threads(topicid,subject,replies,author,lastpostdate) values (4,'Swings',0,'p@q.com','1/27/2008 03:12:51 PM'); 
insert into messages(threadid,author,date,message) values(1,'a@b.com','1/27/2008 2:44:39 PM','Where can I find Java tutorials.');
insert into messages(threadid,author,date,message) values(1,'c@d.com','1/27/2008 2:45:28 PM','Please visit www.java.sun.com');
insert into messages(threadid,author,date,message) values(1,'c@d.com','1/27/2008 2:46:41 PM','Do a Google serach for more tutorials.');
insert into messages(threadid,author,date,message) values(2,'x@y.com','1/27/2008 2:48:53 PM','Please provide some Beginner tutorials.');
insert into messages(threadid,author,date,message) values(3,'p@q.com','1/27/2008 3:12:51 PM','How many finds of layout managers are there?');
insert into messages(threadid,author,date,message) values(2,'l@m.com','2/2/2008 1:06:06 PM','Search on Google.');
 

View 5 Replies View Related

Reporting Services :: SSRS Report Does Not Display Resultset Through Dataset Returns Resultset

Oct 10, 2012

I am creating a simple SSRS table report through Report Builder. My dataset is looking for the stored procedure . When I execute the Stored procedure through SSMS I get resutset for certain parameters. I execute the dataset  (Store procedure) through query designer in dataset properties and I get results back. But when I try to run the report and see the preview, I do not get any results displayed. I been looking on the same issue form last 3-4 days and have not found any clue.

Following is the stored procedure I am using. Also I am passing multivalued parameter through report as well, and I am using spilt function to seperate the libraryid I am reading from parameter values. This works fine. I have similar kind of four other reports and with different stored procedure which exactly follow the same method , like multivalue parameters and other criteria are also very similar. All other reports works just fine.. This perticular report has issue for displying results, following is the stored procedure I am using 

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

[code]....

View 4 Replies View Related

Row Numbering

May 30, 2008

Hello,

I am having trouble getting the results I am looking for from this query:

select ROW_NUMBER() OVER(PARTITION BY TransTime, DriverNo ORDER BY TransTime) as CustCount
, ROW_NUMBER() OVER(PARTITION BY Left(ToName,2), TransTime, DriverNo ORDER BY TransTime) As DelCount
, DriverNo
, Convert(VarChar(8), TransTime, 108) As TransTime
, Left(ToName,2) As AirPortCode
from transactions

The results I am trying to get would be like this:

CustCount DelCount DriverNo TransTime AirPortCode
-------------------- -------------------- -------- --------- -----------
1 1 042000 04:00:00 NW
1 2 042000 04:00:00 NW
1 1 042000 06:51:00 AA
1 1 042000 08:45:00 NW
1 1 042000 08:52:00 NW
1 1 042000 10:30:00 NW
1 1 042000 10:45:00 NW
2 1 042000 10:45:00 AA
1 1 042000 11:30:00 NW
1 2 042000 11:30:00 NW

But the closest I have gotten is:

CustCount DelCount DriverNo TransTime AirPortCode
-------------------- -------------------- -------- --------- -----------
1 1 042000 04:00:00 NW
2 2 042000 04:00:00 NW
1 1 042000 06:51:00 AA
1 1 042000 08:45:00 NW
1 1 042000 08:52:00 NW
1 1 042000 10:30:00 NW
1 1 042000 10:45:00 NW
2 1 042000 10:45:00 AA
1 1 042000 11:30:00 NW
2 2 042000 11:30:00 NW

The CustCount field should read 1 if there is only one unique AirPortCode during the TransTime with the specific DriverNo, but the query is counting both rows during that transtime. Any ideas?

Thanks.

View 9 Replies View Related

Numbering

Oct 5, 2005

Hi guys,

I have a table with 3 col like below

col1 col2 col3
LastName FirstName Address City
Nilsen Fred Kirkegt 56 Stavanger
Rasmussen Nina Storgt 67

none of them are unique, some are null and there are about 800,000 rows

I want to insert a col before 1 or after 3 and have numbering from 1 to the last row. How can I do that?


Thank you
Mina

View 5 Replies View Related

Numbering In SQL

May 19, 2006

I have table with 10-20 rows with field P6 which is empty. I want toupdate numbers to P6 starting 1 and increasing by 1. I suppose it isdone by triggers but I don't know how to do that. Help :-)

View 7 Replies View Related

Row Numbering...

Sep 20, 2007

Good Day everyone...


I created a simple report for getting the top selling items of a store. I am getting the report well but my team mate requested to include a number at the first column that will hold the ranking of the item. Is there a function for including a rowrank or someway that i can add a column to my query that will provide the rowrank. Please show me how... c",)

thanks in advance guys...

View 4 Replies View Related

Please Help..Query With Numbering

Mar 31, 2006

Is It possible that, if there are 5 rows selected out, each row will automatically have the number from 1 to 5?

for example, after select query, results:
---------------------------------------
1Tom100
2May93
3Apple87
4Johnny72
5Noel67

View 2 Replies View Related

Help Needed On Numbering

Sep 19, 2007

Hi All,

I've upsized my database from access to SQL server, now im very new to SQL etc and i've been reding up on sqential numbering etc and my mind is buzzing with ideas. This is my problem.

I have a table and a colum called PIR ID this colum needs to start the numbering at 372 and increment by 1 each time. Now initially this was o.k by using identify. However it's a problem when 2 users open the form in access they are given the same number.

Now my though on this was to initially have a seperate table called new PIRID and hold the next bumber in there, so that a new number is taken from the list and entered into the record on save ( does that make sense) now the code i've got up to so far is that i've created the table and i get stuck from there.

Can anyone help me with the code of format of code i'm meant to be using, i'm under the understanding that to perform this funtion i may have to use a trigger of some sort.

Thanks In advance
Carol

View 1 Replies View Related

Auto Numbering

Jul 23, 2005

Hello,For analyses and reporting I would like to add a 'ranking' to atable/view.Example:Using the 'order by desc' clause in query I get a list of Customersordered by Turnover (descending). I would like to add that rankingnumbers (same as recordnumbers) in the query. I would like to have thefollowing result:Cust_nr Cust_Name Turnover_2004 Ranking002234 Bayer 139.000 1003456 Rentokill 123.456 2001231 Air France 105.000 3etc.When the 'ranking' is part of the query/table I can use this ranking inan other query.Important: This questions is not about making an (empty) table structurefor filling in by an application and generating a new unique number eachtime a record is added.I hope you can help me.Thanks,Hans*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!

View 2 Replies View Related

Numbering A Query

Jul 20, 2005

Is there a quick way to number a query?ie I want to number the records returned by a recordset consecutively.This seems like it should be simple but I haven't figured out how to do ityet.Any help is appreciated!TIACarter

View 2 Replies View Related

Auto Numbering

Feb 23, 2008

I have created an ID column for auto numbering, but in the properties, they didn't have the option of setting it to auto numbering, and how am i suppose to set or code it to autonumbering.

Please and thankyou

View 3 Replies View Related

Numbering In Group

Jan 1, 2007

I want to add numbering in group in the reports.(number each row in the detail)

when I worked with access it was possible.

can I do it in the report services?

thanks!

View 1 Replies View Related

Consecutive Numbering WITHOUT Identity

Nov 23, 2006

Hi,I'm
trying to insert records from one table into another table. The
destination table has a ROWID field which cannot be an identity key,
but needs to 'act like' an identity key and have its value populated
with (Max(ROWID) + 1) for each row added to the table.To my
thinking, simply using (Max(ROWID) + 1) in my SELECT statement will not
work as it will only be evaluated once so if I am adding 1000 records
and Max(ROWID) is 1234, all 1000 entries will end up having a ROWID of
1235.Is there a way to accomplish this?Thanks

View 2 Replies View Related

SQL Unique ID - Auto Numbering

May 31, 2008

I know its a simple question. But couldnt find a solution of my own.
My SQL 2005 table has 2 fields, namely - id (primary key), comments(varchar).
I want to automatically increment the value of 'id', starting from 1000.
Is there any DataType which i can specify at the time of table designing, so that the value of the id
field will be automatically incremented, upon inserting each new record.
Im using SQL 2005 Express Edition. Can anyone tell, how to do that ?
Thanks

View 8 Replies View Related

Numbering Issues For Projects

Jun 5, 2008

I'm creating an application to track project issues.  I would like to have the issue number start over at 1 for each project.  I would like to have the issue numbers assigned to each issue in sequential order for each project.  Below is a brief example of what I need it to do.  I don't know where to even start to try to figure this out.  Thanks
ProjectNumber, IssueNumber
TEST0001, 1TEST0001, 2TEST0002, 1TEST0003, 1TEST0003, 2TEST0001, 3TEST0004, 1TEST0003, 3TEST0002, 2TEST0005, 1

View 18 Replies View Related

Table - 'Auto-numbering'

Sep 10, 2004

Hi guys,

Is it possible to make a table with 'Auto-numbering'? I mean the same function as in MS Access.

Thanks in advance.

View 2 Replies View Related

Insertingupdate Line Numbering

Oct 11, 2004

I have a table which contains order information, which I would like to have line number associated with them

what SQL statement do I use in order to add the line numbering for each line, and have it dependent on reseting on the sales order number?

View 4 Replies View Related

Problems With Week Numbering

Jan 7, 2005

Hi!

I'm trying to get a MSSQL view to return some data marked with a week number based on a date (which is present on every row in the source table). Since I reside in Denmark, I would like the numbering to follow the rule '1. week of a year is the first week with a least 4 days in it'. My instance of MSSQL however is convinced that the rule '1. week starts 1. January'.

Are there any ways to configure my way out of this problem??

Examples:
This year 1. and 2. January is returned as week=1, 3. January is returned as week 2.
I would like 1. and 2. to be week=53 and 3. to be week=1.

Thanx in advance! :)
Ult

View 7 Replies View Related

Sequential Numbering Problem

Jul 27, 2006

I've created a sproc that will provide a recordset for an Access report via a pass-thru query. The report is a production schedule.
Some of the runs on the schedule have a note associated with them. I need
to be able to number these notes, so that they can be displayed in the report
bibliography style. When I populate the data in the sproc, if the "notes"
field in my table contains any data I display a 1, else it's a 0
Like:

SELECT NOTE_FLAG = CASE WHEN ISNULL(SCHED_NOTE,'')<>'',1,0
FROM MASTER_SCHEDULE


The problem is, I really need to display sequential numbers instead of 1's

If I create a base set with this:

CREATE TABLE #TMPRST (
RECID INTEGER,
PRODUCT VARCHAR(10),
QTY FLOAT,
NOTE_FLAG INTEGER)

INSERT INTO #TMPRST
SELECT 1, 'ABC123', 4, 0
UNION ALL
SELECT 4, 'DEF123', 5, 1
UNION ALL
SELECT 5, 'ABC456', 12, 0
UNION ALL
SELECT 13, 'PQR789', 10, 1



How do I go back and convert the note_flag column to read
... 0
... 1
... 0
... 2

View 14 Replies View Related

Identity Column Numbering

Mar 6, 2006

We're performing an insert and the column that has identity is numbering the records without a problem, but it's assigning duplicate ID's on the records. Does Autoincrement or Autonumbering need to be turned on somewhere?

spencer

View 9 Replies View Related

Add Leading Zero For Legal Numbering

Jan 31, 2008

Good afternoon,

I hope the title is self explaining. Here is an example of what i would like to do:

Before...
1
1.1
1.1.1
1.2.1
1.3.1
1.10.1

After...
01
01.01
01.01.01
01.02.01
01.03.01
01.10.01

Thanks,
Phil.

View 6 Replies View Related

Page Numbering Per Group

Nov 8, 2007



I don't think this is possible, but I promised my users I would bring this question to the forum. The users want to have the page numbering change per each group on the report. The report is large, and there are up to 5 pages in each group. I have a large List Control surrounding the many tables on my report that controls the over all report grouping. Everything looks great and the users are pleased.

But when I try to add the Global!PageNumber and Global!TotalPages to the bottom of the List Control I get the error that the Globals properties can only be used in the Page Header and Page Footer section.

Is there any way around this? I could not think of a way around it, but I am not an expert in Reporting Services by any means.

Thank you,

T.J.

View 4 Replies View Related

Sequential Numbering In Queries

Feb 7, 2008

Hi,

I've a column say page#. This has by default 4 pages which I'm numbering as 1,2,3,4. I'll be adding pages to this table and the number needs to start from 5 (since 4 pages are already present)

Page# is not an identity column. I want to know if theres a function which can do the trick.

Thanks for your help!

Subha

View 4 Replies View Related

Page Numbering Per Grouping

Mar 28, 2008

HI

Has anyone figured out how to reset the page numbers after a grouping and have it display in the format €˜Page X of Y€™? I can get it to reset the page number for each group and display €˜Page X€™ but it€™s the €˜of Y€™ part that is a problem.

Thanks,

View 6 Replies View Related

Group Numbering Issue

Dec 20, 2006

Hi everyone,

The problem is about numbering groups. I'm trying to display data like this-

1. U.S

1.1 San Francisco

1.1.1 employee1

1.1.2 employee2

1.2 Dallas

1.2.1 employee3

2. UK

2.1 London

2.1.1 employee4



I've tried using RunningValue(1, Sum, "group_name") but it gives erroneous results. I'm using 3 lists, one at each group level. The outermost list (1st list) is grouped by "country" (group_1), 2nd one is grouped by city (group_2) and the innermost (3rd one) by employee name (group_3).

I can't figure whats wrong. Can anyone help me?

Thanks in advance.

View 4 Replies View Related

Numbering The SQL Query Statements

Jan 4, 2007

Using the TOAD application for Oracle, I am able to number the SQL query lines for readability. Can the same be done for SQL Server 2005?

View 4 Replies View Related

Sequence Numbering Items In A Cart

Dec 15, 2005

I'm looking for any help/tricks on creating an item numbering system in a MSSQL database. The object is to number the items in a cart from 1 to whatever and have the ability for the user to change that sequence. The client wants the ability to order the items any way they choose by changing the sequence number. This process would require.
1. Starting at one (1) for the first item in the cart and incrementing from there.2. If I have 10 items and I change item 3 to 5,  items 4 and 5 have to increment down by one and 6-10 would stay the same. (and vise versa moving item 3 to item 1)3. If I have 10 items and I delete item 4, 5-10 must incremet down by one.
On 1 my first though in adding items is doing a select count to see if any items exist in the cart. If they don't assign the number one. if it does do a max on the sequence column and increment by one.
on 3 I would simply delete the item and do an update on all items with seq# > then the deleted Seq#
on 2 I'm not sure yet.
Am I on the right track and are there any tricks to doing this? Any help would be appreciated. This would all be done in stored procedures.

View 3 Replies View Related







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