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
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
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.
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:
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?
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 :-)
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",)
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.
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!
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
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.
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
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
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
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
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.
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?
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.
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.
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.
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'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.
I am having trouble making this DAX formula work. This is my test data including the column "rank" which is a row_number with partition by generated using T-SQL. (The nature of the data is that the "Measure" will always increase cumulatively per month and I want the maximum "measure" to equal a rank of 1).What I need is a second RANK column which updates dynamically so that if I select just some of the Months, they will rank from 1 +. E.g:
Hello,I am creating a new database and I was advised to use Sequential Guids.I was reading some information and, as far as I understood, I can use NEWSEQUENTIALID. This can be used when I have a uniqueidentifier column as the key of a clustered index to avoid fragmentation during insert. Ok, so I use NEWSEQUENTIALID instead of NEWID.But I will use LINQ most of the time instead of Stored Procedures.So can I specify in my tables scripts to use Sequential Guids when, for example, a record is created? And am I right when using Sequential Guids?Here is a part of my code:-- Blogs ... create table dbo.Blogs ( BlogID uniqueidentifier not null constraint PK_Blog primary key clustered, Title nvarchar(400) null, Description nvarchar(2000) null, CreatedDate datetime null )
-- Posts ... create table dbo.Posts ( PostID uniqueidentifier not null constraint PK_Post primary key clustered, BlogID uniqueidentifier not null, AuthorID uniqueidentifier not null, Title nchar(1000) null, Body nvarchar(max) null, UpdatedDate datetime not null, IsPublished bit not null, constraint FK_Posts_Blogs foreign key(BlogID) references dbo.Blogs(BlogID) on delete cascade, constraint FK_Posts_Users foreign key(AuthorID) references dbo.Users(UserID) on delete cascade Thanks,Miguel
In Foxpro I would often run sequential queries on data. Each query would store the results in a cursor, which would be the datasource for the next query. It was an easy way to write several simple queries to accomplish something complex.
Like this:
select <fields> from table1 where <condition> into cursor work1 select <fields> from work1 where <condition>
Hi I have a database that has a table. I have a page that you can enter info into text boxes and insert into the database table. They are supposed to be entered in numerical order. 1,2,3, etc. I have a primary key that is an integer for this function but for some reason after entering a certain amount of records the number id be out of order. So for instance if I enter 10 records they will all be there but some may be out of order. 7 will be before 6 or something of that nature. Does anyone have any idea what may be causing this.