Hii all,
i have a problem to get every second row in a table with condition 1 column has a same value,
example: i have 1 table is called 'HP'
with column id,nik,hp,status_aktif
id | nik | hp | status_aktif
1 | 2010010269 | 08123456789 | 1
2 | 2010010269 | 08567891011 | 1
3 | 2010010271 | 08112347891 | 1
4 | 2010010271 | 08568391020 | 1
can anyone help me,
select 2nd row with condition 1 column has a same value with 'QUERY SELECT'
result:
2 | 2010010269 | 08567891011 | 1
4 | 2010010271 | 08568391020 | 1
Regards,
Octo
4 2094
Should be something like this - SELECT id, nik, max(hp), status_aktif
-
FROM [Your table here]
-
GROUP BY nik, id, hp, status_aktif
Only works if:
1. you only have 2 records with the same nik
2. your 2nd hp value is bigger than the 1st one
Thanx for your reply Mr.colintis..
It's not working. all records is show in result.
1. There's many records in this table
2. It's random 'hp' value between 1st hp value and 2nd hp value
Try this one if it can, as this is the closest one I can think of. - SELECT TOP 1 id, nik, hp, status_aktif
-
FROM [Your table here]
-
WHERE id NOT IN (SELECT TOP 1 * FROM [Your table here] GROUP BY nik)
-
GROUP BY nik, id, hp, status_aktif
You can use a DCount() function with in the WHERE parameter a test for nik being equal, status_aktif = 1 and hp <=.
This will add a sequence row numbering for each nik and allows you to filter for value 2.
Getting the idea ?
Nico
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Amber |
last post by:
There are times when you will need to highlight or otherwise modify
the contents of a particular DataGrid row-column value based upon the
value in the column. In this example we will select the...
|
by: Microsoft News Group |
last post by:
I am trying to get a value from the MIN column in my database. I can not
seem to get the IF statement to be true, even thou my debugging says the
column value is 0, but it is not hitting the...
|
by: kowndinya |
last post by:
Hai,
I have created a program in vb6 , MSChart and it is working fine.
This chart shows monthly sales values ( columncount =1) and chart type is vtChChartType2DBar
my problem is, I want to add...
|
by: =?Utf-8?B?QmFidU1hbg==?= |
last post by:
Hi,
I have a GridView and a SqlDataSource controls on a page. The SqlDataSource
object uses stored procedures to do the CRUD operations. The DataSource has
three columns one of which -...
|
by: Joe Meng |
last post by:
Greetings,
I've seen this question asked and answered here, just not completely yet.
I'm wondering how to use a column value as a table name in another query. So far it's looking like you must...
|
by: chumma |
last post by:
Hi,
i knew little bit about "Select MAX(col_name) from <table_name>" function using in mysql to find the largest value in a particular column. Now i want to know with the same fact i`ve to find...
|
by: TF |
last post by:
Very newbie question and I hope this is the right group. I have a
table on a web page which contains info about paint colors. One column
contains the hex value for the color's RGB value. I want...
|
by: Manikandan |
last post by:
Hi,
I have table with three columns as below
table name:exp
No(int) name(char) refno(int)
I have data as below
No name refno
1 a
2 b
3 c
|
by: vinodkus |
last post by:
dear sir/madam
I have a problem . I have a table of field name ,roll_name, age
I have to show name and roll_number in combo box list. please help me
i m using it
<select name=id1>
<option...
|
by: sk27ahmed |
last post by:
Hi
Any one can show me how to access datagridview column value on column checked unchecked.
I create one column in datagridview of type checkbox,and on button click i write code to select all...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |