Re: SQL statement for multiple classes

2021-03-12 Thread Skylar Thompson
Yeah, one of the limitations in SQL is that it's strongly-typed, which means that the type of each query (including row structure) has to be known before execution. Other database engines like PostgreSQL provide extensions written in a procedural language (I think C) that work around this by return

Re: SQL statement for multiple classes

2021-03-12 Thread Loon, Eric van (ITOP NS) - KLM
Hi Marc, This was exactly what I was looking for, thank you VERY much!!! Kind regards, Eric van Loon Air France/KLM Storage & Backup -Original Message- From: ADSM: Dist Stor Manager On Behalf Of Marc Lanteigne Sent: vrijdag 12 maart 2021 17:10 To: ADSM-L@VM.MARIST.EDU Subject: Re: SQL

Re: SQL statement for multiple classes

2021-03-12 Thread Loon, Eric van (ITOP NS) - KLM
Hi Skylar, Your query returns multiple lines for the same node if a node uses multiple classes: Node_name class_name amount Nodename1 Class1 11231231 Nodename1 Class2 31223 I'm looking for a way to have everything in one line, like: Node_name Clas

Re: SQL statement for multiple classes

2021-03-12 Thread Marc Lanteigne
Hi Eric, I was actually trying to something similar with different data and tables a few weeks ago. With the help of a co-worker, we figured it out. It has to be a 2 step process. First you get a list of all the values you want as the column headings, in your case, the class name: select distinc

Re: SQL statement for multiple classes

2021-03-12 Thread Skylar Thompson
Hi Eric, You can part of the way there with GROUP BY: SELECT node_name,class_name,COUNT(*) FROM archives GROUP BY node_name,class_name This will give you one row per (node_name,class_name) tuple. In order to get row values as columns, though, you need to do a pivot (aka crosstab), which I'm not

SQL statement for multiple classes

2021-03-12 Thread Loon, Eric van (ITOP NS) - KLM
Hi everybody, I'm trying to figure out how to create a SQL query to retrieve the amount of files, per management class, per node in just one query. The ideal output would be: Nodename Class1 Class2 Class3 Mynode1 1234