I have table which has a column of type json with name "demographi c". I want to compare keys by their values predefined by me and the result of that should be the name of the key and not the value which i will save to another column's rows.
The json columns looks like a this: - {"he" : {"he_vakiy" : 29384, "he_naiset" : 14803, "he_miehet" : 14581, "he_kika" : 1485, "he_0_2" : 850, "he_3_6" } }
I want to compare f.ex "he_naiset" and "he_miehet" and the one that has higher value should return the name of the "key" ;
Ive tried something like this: - select greatest(demographics->'he'->>'he_miehet',demographics->'he'->>'he_naiset') as greatest from demographics;
Which will compare the values and return the higest values. But i dont know how i can get the name of the key.
I also tried something like this from : - with cte as
-
(
-
select *
-
, genre.key as genre
-
, row_number() over (partition by id order by value desc) as ord
-
from base.maakunta
-
cross
-
join lateral json_each_text(base.maakunta.demographic->'he') genre
-
-
)
-
select genre, value,ord
-
from cte
-
where ord = 1
-
;
But this one compares all the keys inside the json .
0 1859 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Chaz |
last post by:
Hello, I hope someone can help me out. I am going to be taking the
third step in a programming class soon(I took the previous two a while
ago at a different school) and in an effort to get back up to speed, I
bought the Dietel book How To Program 5th ed. I am going through some
examples trying to work them out, and have been doing pretty good, but
came across one exercise that has me stumped. It's a card shuffling
program that deals 5...
|
by: teddysnips |
last post by:
I have a table called WorkItem. It models a chunk of work done during
a working day.
It has two columns that I'm interested in:
Start (smalldatetime) - the TIME the work block is begun
Duration (int) - the duration in minutes of the work block.
In another table called OvertimeRates I have information about rate
multipliers and a column that tells me the TIME that the rate
|
by: BStorm |
last post by:
Does anyone know the best way to update a DataTable row column using
specific values for a multipart primary key?
For example, updating an OrderAmt column in an OrderDetail table where the
primary key consists of an OrderNo and DetailSeqNo?
|
by: Ying Lu |
last post by:
Hello,
Under mysql, we have "desc tablename" to get the detail information
about a table. My question is about to get column name, and column type
for a specific table under PostgreSQL through JDBC.
Assume we have a table named "test". Under PSQL, we can input "\d test"
to see the details about table "test" successufully. However, my main
purpose is trying to get column name, column name of a table through JDBC.
|
by: prasath03 |
last post by:
Dear All,
Can anybody help me about my coding, i'm inserting the image file to database using jsp. When i execute the code, the following error is occurred:
java.sql.SQLException: Insert Error: Column name or number of supplied values does not match table definition.
I'm using MS-SQL Server.
My code is:
| |
by: rompicherla |
last post by:
Hai every body,
i am using postgres 7.3 version, For a varchar (string) data column, in this column i filled the numbers (1,2,3 ...10,11,..... etc) alone. i sorted this column, but sorting values are comming 1,10,11,2,20.... etc like. but i need 1,2,3,10,22 like.
please tell me the solution for this problem.
thanks and regards,
|
by: nev |
last post by:
i declared 2 datatables:
dim dtt1 as datatable = ds.datatable1
dim dtt2 as datatable = ds.datatable2
dtt1 has firstname, lastname columns
dtt2 has firstname column
when i filter dtt1 by lastname, there will be a lot of firstnames
|
by: MarkoKlacar |
last post by:
Does anyone know a good script for comparing RBG values?
The values are hexadecimal and I need to find a color that is closest to the one I'm comparing. I've tried a lot of stuff but I can't get the results I want.
Picture this:
$BaseColor = BLACK
$ColorOne = YELLOW
$ColorTwo = DARKGREY
What I need is a way to compare the colors so that it returns DARKGREY.
|
by: rizwan6feb |
last post by:
I have a DataTable with thousands of records, i want to show these records on per page basis ( i.e a DataGridView showing first 20 records and next button to show next 20 records ...)
To achieve this, i have added an Autoincrement Column to the DataTable so that i can use a filter on the Autoincrement Column to get the desired 20 records from the DataTable. I have used the following code
Dim dc As New...
|
by: Radha Shyam |
last post by:
My question is how can I combine two sets of JSON for example one set comes from one datatable like this:
"ID": 1, "SHORT_NAME": "B", "CARRIER_NAME": "Carrier A"
Another one with multiple values comes from another datatable:
{ "YMDH": "2009-03-07 00:00:00.000", "SELL_DURATION": 222.999995 }, { "YMDH": "2009-03-07 01:00:00.000", "SELL_DURATION": 75.816664 }, { "YMDH": "2009-03-07 02:00:00.000", "SELL_DURATION": 39.349995 }, { "YMDH":...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |