473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Controlbreak flag in result?

I need a control break flag in my result when a certain value is
different to the previous.

A table/result like this:

PRODUCER ARTICLE
80000 1 <- flag = 1
80000 2 <- flag = 0
80000 3 <- flag = 0
80001 1 <- flag = 1
80001 2 <- flag = 0
80001 3 <- flag = 0

any ideas?

Bernd
Apr 18 '06 #1
2 1490
Ian
Bernd Hohmann wrote:
I need a control break flag in my result when a certain value is
different to the previous.

A table/result like this:

PRODUCER ARTICLE
80000 1 <- flag = 1
80000 2 <- flag = 0
80000 3 <- flag = 0
80001 1 <- flag = 1
80001 2 <- flag = 0
80001 3 <- flag = 0

any ideas?

Bernd


select
producer,
article,
case when rn = 1 then 1 else 0 end as flag
from
(select
producer,
article,
rownumber() over (partition by producer order by article) as rn
from
yourtable) as x;

Apr 18 '06 #2
Ian wrote:
any ideas?


select
producer,
article,
case when rn = 1 then 1 else 0 end as flag
from
(select
producer,
article,
rownumber() over (partition by producer order by article) as rn
from
yourtable) as x;


Thanks a lot. I was able to compress this a little bit into

case when (rownumber() over (partition by producer order by article ))=1
then 1 else 0 end as cbflag

without the additional select (don't know why it works, SQL is sometimes
a mystery to me).

Bernd
Apr 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
by: Shayan | last post by:
Is there a boolean flag that can be set atomically without needing to wrap it in a mutex? This flag will be checked constantly by multiple threads so I don't really want to deal with the overhead...
3
by: mrhicks | last post by:
Hello all, I have a question regarding efficeny and how to find the best approach when trying to find flag with in a structure of bit fields. I have several structures which look similar to ...
9
by: Erik Leunissen | last post by:
L.S. I've observed unexpected behaviour regarding the usage of the '#' flag in the conversion specification in the printf() family of functions. Did I detect a bug, or is there something wrong...
2
by: Blue Man | last post by:
Hello I want to create a link that open and close a panel. but i can't save a variable as a flag to test each time if the panel is open or not, this is my code : int flag=0; private void...
1
by: Uri Dimant | last post by:
Hi,friends I meant Flag on text editor. It allows you to move from flag to flag only within one class/module. If you put another flag within different module/class in the same project then it...
4
by: John Salerno | last post by:
I created this enumeration: enum Status { Off = 0, Red = 1, Yellow = 2, Blue = 4, Overload = 8
1
by: Craig Buchanan | last post by:
I am using flag as the identifier for various security settings. For instance: Public Enum SecurityEnum Read=0 Write=1 Delete=2 ... End Enum
3
by: Jim Archer | last post by:
Hi All... I'm been fighting this problem for a few days now, and it seems like it should be simple. But the solution has eluded me so far... I need to flag a record when it is updated or when...
2
by: Efi Merdler | last post by:
Hello, As I understand it is impossible in xslt to change the value of a variable after you assigned a value to it. I would like to simulate a flag. For example if something happens in template...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.