Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
windcent
Starting Member
6 Posts |
Posted - 2014-11-05 : 12:58:35
|
I need to create a view that counts in one of the colums. The tricky part for me is that it should only count to three, then start on 1 again and count to three again.Example1 - car2 - bike3 - Motorbike1 - Boat2 - Airplane3 - Motorboat1 - Bicycle |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-11-05 : 13:36:07
|
Please post you SQL Query for the view, minus the counting column |
|
|
windcent
Starting Member
6 Posts |
Posted - 2014-11-05 : 14:11:00
|
USE [Database]GO/****** Object: View [dbo].[viewTest] Script Date: 05.11.2014 18:37:11 ******/SET ANSI_NULLS OFFGOSET QUOTED_IDENTIFIER OFFGOALTER view [dbo].[viewTest] AS SELECT ol.OrdNo, ol.ProdNo, ol.Descr,ol.DPrice, pr.PictNo, pr.NoteNm as DescriptLongFrom ordln olleft join Prod pr on ol.ProdNo = pr.prodno GO |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-11-05 : 17:00:29
|
OK -- so which column is Motorbike in and which column determines that the count should begin at 1 again? |
|
|
windcent
Starting Member
6 Posts |
Posted - 2014-11-05 : 17:18:12
|
The viewSELECT ol.OrdNo, ol.ProdNo, <<Counting>>100 - car - 1123 - fish - 2100 - bike - 3200 - Lion - 1 100 - Motorbike - 2100 - Boat - 3 200 - Dog - 1 100 - Airplane - 2 100 - Motorboat - 3100 - Bicycle - 1 If i make a select from the view with a whereSelect <<count>>, ol.ProdNo from the db.view where ol.OrdNo = 100I would like to have the result:1 - car2 - bike3 - Motorbike1 - Boat2 - Airplane3 - Motorboat1 - Bicycle |
|
|
|
|
|