# Error Query SQL multiple select

**URL:** <https://forum.inductiveautomation.com/t/error-query-sql-multiple-select/80669>\
**Category:** Ignition\
**Tags:** database, ignition81, vision\
**Created:** [October 18, 2023, 10:27pm UTC](https://forum.inductiveautomation.com/t/error-query-sql-multiple-select/80669 "2023-10-18T22:27:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![antonio.sanchez](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@antonio.sanchez](https://forum.inductiveautomation.com/u/antonio.sanchez)\
**Post date:** [October 18, 2023, 10:27pm UTC](https://forum.inductiveautomation.com/t/error-query-sql-multiple-select/80669/1 "2023-10-18T22:27:39Z")

</div>

Hello everyone

I have a problem with the following query

```auto
SELECT (SELECT Dato FROM Dato_Medidor WHERE Linea = 'ELFO_006_Oficinas') as 'ELFO_006',
(SELECT Dato FROM Dato_Medidor WHERE Linea = 'ELFO_007_Oficinas') as 'ELFO_007',
(SELECT Dato FROM Dato_Medidor WHERE Linea = 'ELFO_008_Oficinas') as 'ELFO_008',
(SELECT Dato FROM Dato_Medidor WHERE Linea = 'ELFO_009_Oficinas') as 'ELFO_009',
(SELECT Dato FROM Dato_Medidor WHERE Linea = 'ELFO_010_Oficinas') as 'ELFO_010',
Fecha
FROM Dato_Medidor where CONVERT (DATE,Fecha) = CONVERT (DATE,GETDATE ())

```

it returns the following error

**\> Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, \<, \<= , \>, \>= or when the subquery is used as an expression.**

I want to divide the data that comes from the "Data" field into columns

---

<div class="post-metadata">

**Author:** ![carlosbqz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carlosbqz/32/52324_2.png) [@carlosbqz](https://forum.inductiveautomation.com/u/carlosbqz)\
**Post date:** [October 19, 2023, 12:58am UTC](https://forum.inductiveautomation.com/t/error-query-sql-multiple-select/80669/2 "2023-10-19T00:58:44Z")

</div>

Hello Antonio,

Are you using SQL Server, MySQL, Oracle or Postgre?

I think you can achieve what you want to do (if it is SQL Server) with a PIVOT, I hope you have a column for the date 😆, check this out:

```auto
SELECT pvt.* FROM
(
	SELECT Fecha, Linea, Dato FROM Dato_Medidor
) src
PIVOT
(
	MAX(Dato) FOR Linea IN ([ELFO_006_Oficinas], 
	[ELFO_007_Oficinas], [ELFO_008_Oficinas], [ELFO_009_Oficinas], 
	[ELFO_009_Oficinas], [ELFO_010_Oficinas])
) AS pvt

```

If your database is not SQL Server, then I will have to do some research for a similar option (I think I did this in Oracle too).

You can send me a private message in spanish if you want as I asume you speak spanish by reading the names of your columns 🤔

---

<div class="post-metadata">

**Author:** ![chen\_zhe](https://avatars.discourse-cdn.com/v4/letter/c/c0e974/32.png) [@chen\_zhe](https://forum.inductiveautomation.com/u/chen_zhe)\
**Post date:** [October 19, 2023, 9:37am UTC](https://forum.inductiveautomation.com/t/error-query-sql-multiple-select/80669/3 "2023-10-19T09:37:54Z")

</div>

about the = \> \< you should use " "
