-
Notifications
You must be signed in to change notification settings - Fork 0
Basic Query
Ready to flex your SQL muscles on JSON data? You're in the right place! In this guide, we'll walk through everything from simple picks to complex filtering, sorting, and our super-smart Master-Detail output. Let's turn that messy JSON into pure gold! ๐โจ
Check out this structure! We've got some global info at the root and a list of cool team members to play with. โฌ๏ธ
{
"Organization": "Tech Core Global",
"TotalBudget": 50000,
"Currency": "USD",
"Members": [
{ "Id": 101, "FullName": "Fadhly Permata", "Role": "Lead Architect", "Department": "Core Engine", "Salary": 9500, "Active": true },
{ "Id": 102, "FullName": "Budi Santoso", "Role": "Senior Developer", "Department": "Core Engine", "Salary": 7500, "Active": true },
{ "Id": 103, "FullName": "Sari Wijaya", "Role": "UI Designer", "Department": "Frontend", "Salary": 6000, "Active": false },
{ "Id": 104, "FullName": "Andi Pratama", "Role": "DevOps Engineer", "Department": "Infrastructure", "Salary": 8000, "Active": true },
{ "Id": 105, "FullName": "Rina Gunawan", "Role": "QA Engineer", "Department": "Infrastructure", "Salary": 5500, "Active": true }
]
}Here are 15 battle-tested scenarios supported by JQL.Net. Let's go! ๐๐จ
Just need a single value from the top level? Easy peasy!
SELECT $.Organization, $.Currency FROM $Output:
{
"Organization": "Tech Core Global",
"Currency": "USD"
}Want to see every single member in the array? Say no more! ๐ฆ
SELECT * FROM $.MembersOutput:
[
{ "Id": 101, "FullName": "Fadhly Permata", "Role": "Lead Architect", "Department": "Core Engine", "Salary": 9500, "Active": true },
{ "Id": 102, "FullName": "Budi Santoso", "Role": "Senior Developer", "Department": "Core Engine", "Salary": 7500, "Active": true },
...
]Rename your fields on the fly to make them look pretty! โจ
SELECT FullName AS Name, Role AS Position FROM $.MembersOutput:
[
{ "Name": "Fadhly Permata", "Position": "Lead Architect" },
{ "Name": "Budi Santoso", "Position": "Senior Developer" },
...
]Who's making the big bucks? ๐ธ
SELECT FullName, Salary FROM $.Members WHERE Salary > 8000Output:
[
{ "FullName": "Fadhly Permata", "Salary": 9500 },
{ "FullName": "Andi Pratama", "Salary": 8000 }
]Filtering with multiple conditions like a pro. ๐ต๏ธโโ๏ธ
SELECT FullName FROM $.Members WHERE Department == 'Core Engine' AND Active == trueOutput:
[
{ "FullName": "Fadhly Permata" },
{ "FullName": "Budi Santoso" }
]Need to find members with specific roles? JQL.Net handles it smoothly! ๐ค
SELECT FullName, Role FROM $.Members WHERE Role == 'UI Designer' OR Role == 'QA Engineer'Output:
[
{ "FullName": "Sari Wijaya", "Role": "UI Designer" },
{ "FullName": "Rina Gunawan", "Role": "QA Engineer" }
]Sort those names alphabetically. ๐ก
SELECT FullName FROM $.Members ORDER BY FullName ASCOutput:
[
{ "FullName": "Andi Pratama" },
{ "FullName": "Budi Santoso" },
{ "FullName": "Fadhly Permata" },
{ "FullName": "Rina Gunawan" },
{ "FullName": "Sari Wijaya" }
]Sort from highest salary to lowest. ๐
SELECT FullName, Salary FROM $.Members ORDER BY Salary DESCOutput:
[
{ "FullName": "Fadhly Permata", "Salary": 9500 },
{ "FullName": "Andi Pratama", "Salary": 8000 },
{ "FullName": "Budi Santoso", "Salary": 7500 },
{ "FullName": "Sari Wijaya", "Salary": 6000 },
{ "FullName": "Rina Gunawan", "Salary": 5500 }
]How many members do we actually have?
SELECT COUNT(Id) AS TotalMember FROM $.MembersOutput:
{ "TotalMember": 5 }Calculating the budget has never been this fun!
SELECT SUM(Salary) AS TotalPayout, AVG(Salary) AS AveragePay FROM $.MembersOutput:
{ "TotalPayout": 36500, "AveragePay": 7300 }Filtering and sorting working together in perfect harmony!
SELECT FullName AS Staff, Salary FROM $.Members WHERE Active == true ORDER BY Salary DESCOutput:
[
{ "Staff": "Fadhly Permata", "Salary": 9500 },
{ "Staff": "Andi Pratama", "Salary": 8000 },
{ "Staff": "Budi Santoso", "Salary": 7500 },
{ "Staff": "Rina Gunawan", "Salary": 5500 }
]Mix root data ($.) and array data, and JQL.Net will automatically group them for you!
SELECT $.Organization, FullName FROM $.MembersOutput:
{
"Organization": "Tech Core Global",
"FullName": ["Fadhly Permata", "Budi Santoso", "Sari Wijaya", "Andi Pratama", "Rina Gunawan"]
}Group your array under a specific key for super clean outputs!
SELECT $.Organization, m AS MemberData FROM $.Members AS mOutput:
{
"Organization": "Tech Core Global",
"MemberData": [
{ "Id": 101, "FullName": "Fadhly Permata", "Role": "Lead Architect", "Department": "Core Engine", "Salary": 9500, "Active": true },
{ "Id": 102, "FullName": "Budi Santoso", "Role": "Senior Developer", "Department": "Core Engine", "Salary": 7500, "Active": true },
...
]
}Master-Detail + Aliasing + Filtering + Sorting. The whole suite!
SELECT $.Organization, m.FullName AS Name, m.Salary FROM $.Members AS m WHERE m.Active == true ORDER BY m.Salary DESCOutput:
{
"Organization": "Tech Core Global",
"Name": ["Fadhly Permata", "Andi Pratama", "Budi Santoso", "Rina Gunawan"],
"Salary": [9500, 8000, 7500, 5500]
}