Spaces:
Sleeping
Sleeping
Carlos Isael Ramírez González
commited on
Commit
·
c1519fa
1
Parent(s):
c6faa56
Error de missing current_question solved
Browse files- examples.json +741 -280
- mojica_agent.py +1 -1
examples.json
CHANGED
|
@@ -1,282 +1,743 @@
|
|
| 1 |
{
|
| 2 |
-
"
|
| 3 |
-
|
| 4 |
-
"
|
| 5 |
-
"
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
"
|
| 9 |
-
"
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
"
|
| 37 |
-
"
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
"
|
| 41 |
-
"
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
"
|
| 47 |
-
"
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
"
|
| 83 |
-
"
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
"
|
| 89 |
-
"
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
"
|
| 93 |
-
"
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
"
|
| 145 |
-
"
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
"
|
| 149 |
-
"
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
"
|
| 153 |
-
"
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
"
|
| 195 |
-
"
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
"
|
| 201 |
-
"
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
"
|
| 205 |
-
"
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
"
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
"
|
| 271 |
-
"
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
"
|
| 275 |
-
"
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"CLIENTES_CERO": {
|
| 3 |
+
"rules": [
|
| 4 |
+
"Usar siempre nombres exactos de columnas",
|
| 5 |
+
"Usar solo las columnas listadas",
|
| 6 |
+
"Prohibido inventar columnas",
|
| 7 |
+
"Para el nombre del cliente usar SIEMPRE 'Razon Social'",
|
| 8 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 9 |
+
"Un cliente cero es aquel que NO tiene compras en las últimas 4 semanas",
|
| 10 |
+
"Para ciudad usar SIEMPRE la columna 'Ciudad' con LIKE",
|
| 11 |
+
"Para filtrar por mes usar: strftime('%m', \"Fecha\") = 'MM'",
|
| 12 |
+
"Para fechas específicas usar DATE(\"Fecha\") con BETWEEN o <= según el caso",
|
| 13 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 14 |
+
"No usar acentos en la query",
|
| 15 |
+
"Agrupar siempre por la columna adecuada cuando se use una función de agregación",
|
| 16 |
+
"Si se compara un cliente específico, usar comillas simples en el valor del WHERE"
|
| 17 |
+
],
|
| 18 |
+
"examples": [
|
| 19 |
+
{
|
| 20 |
+
"pregunta": "¿Cuántos clientes permanecen como cero?",
|
| 21 |
+
"query": "SELECT COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('now', '-28 day')\n);"
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"pregunta": "¿Quiénes son los clientes que siguen inactivos?",
|
| 25 |
+
"query": "SELECT DISTINCT \"Razon Social\"\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('now', '-28 day')\n);"
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"pregunta": "Dame la lista de clientes sin movimientos",
|
| 29 |
+
"query": "SELECT DISTINCT \"Razon Social\"\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('now', '-28 day')\n);"
|
| 30 |
+
}
|
| 31 |
+
]
|
| 32 |
+
},
|
| 33 |
+
"CIUDAD_CERO": {
|
| 34 |
+
"rules": [
|
| 35 |
+
"Usar siempre nombres exactos de columnas",
|
| 36 |
+
"Usar solo las columnas listadas",
|
| 37 |
+
"Prohibido inventar columnas",
|
| 38 |
+
"Para el nombre del cliente usar SIEMPRE 'Razon Social'",
|
| 39 |
+
"Para ciudad usar SIEMPRE la columna 'Ciudad' con LIKE",
|
| 40 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 41 |
+
"Un cliente cero es aquel que NO tiene compras en las últimas 4 semanas",
|
| 42 |
+
"Para filtrar por mes usar: strftime('%m', \"Fecha\") = 'MM'",
|
| 43 |
+
"Para fechas específicas usar DATE(\"Fecha\") con BETWEEN o <= según el caso",
|
| 44 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 45 |
+
"No usar acentos en la query",
|
| 46 |
+
"Agrupar siempre por la columna adecuada cuando se use una función de agregación",
|
| 47 |
+
"Si se compara una ciudad específica, usar comillas simples en el valor del WHERE"
|
| 48 |
+
],
|
| 49 |
+
"examples": [
|
| 50 |
+
{
|
| 51 |
+
"pregunta": "¿Cuántos clientes cero tenemos por ciudad?",
|
| 52 |
+
"query": "SELECT \"Ciudad\", COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Ciudad\" IS NOT NULL\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('now', '-28 day')\n)\nGROUP BY \"Ciudad\"\nORDER BY clientes_cero DESC;"
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"pregunta": "Clientes cero en Guadalajara",
|
| 56 |
+
"query": "SELECT \"Ciudad\", COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Ciudad\" LIKE '%Guadalajara%'\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('now', '-28 day')\n)\nGROUP BY \"Ciudad\";"
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"pregunta": "Clientes cero en Zapopan",
|
| 60 |
+
"query": "SELECT \"Ciudad\", COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Ciudad\" LIKE '%Zapopan%'\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('now', '-28 day')\n)\nGROUP BY \"Ciudad\";"
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"pregunta": "Clientes inactivos en Vallarta",
|
| 64 |
+
"query": "SELECT \"Ciudad\", COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Ciudad\" LIKE '%Vallarta%'\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('now', '-28 day')\n)\nGROUP BY \"Ciudad\";"
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"pregunta": "Total de clientes sin compras recientes por ciudad",
|
| 68 |
+
"query": "SELECT \"Ciudad\", COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Ciudad\" IS NOT NULL\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('now', '-28 day')\n)\nGROUP BY \"Ciudad\";"
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"pregunta": "Clientes que no compraron en las últimas 4 semanas por ciudad",
|
| 72 |
+
"query": "SELECT \"Ciudad\", COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Ciudad\" IS NOT NULL\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('now', '-28 day')\n)\nGROUP BY \"Ciudad\";"
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"pregunta": "Lista de clientes sin compras recientes por ciudad",
|
| 76 |
+
"query": "SELECT \"Ciudad\", \"Razon Social\"\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Ciudad\" IS NOT NULL\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('now', '-28 day')\n)\nORDER BY \"Ciudad\";"
|
| 77 |
+
}
|
| 78 |
+
]
|
| 79 |
+
},
|
| 80 |
+
"PRODUCTO_CIUDAD": {
|
| 81 |
+
"rules": [
|
| 82 |
+
"Usar siempre nombres exactos de columnas",
|
| 83 |
+
"Usar solo las columnas listadas",
|
| 84 |
+
"Prohibido inventar columnas",
|
| 85 |
+
"Para productos usar la columna 'Descripcion'",
|
| 86 |
+
"Para ciudad usar SIEMPRE la columna 'Ciudad' con LIKE",
|
| 87 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 88 |
+
"Para cantidades usar SUM(\"Cantidad\"), para dinero usar SUM(\"Neto\")",
|
| 89 |
+
"Agrupar siempre por la dimensión principal (producto o ciudad) al usar agregaciones",
|
| 90 |
+
"Ordenar DESC para 'más/mayor', ASC para 'menos/menor'",
|
| 91 |
+
"Para filtrar por mes usar: strftime('%m', \"Fecha\") = 'MM'",
|
| 92 |
+
"Para fechas específicas usar DATE(\"Fecha\") con BETWEEN o <= según el caso",
|
| 93 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 94 |
+
"No usar acentos en la query",
|
| 95 |
+
"Si se compara un producto específico o ciudad específica, usar comillas simples en el valor del WHERE"
|
| 96 |
+
],
|
| 97 |
+
"examples": [
|
| 98 |
+
{
|
| 99 |
+
"pregunta": "Cuántos productos se vendieron en la ciudad de Guadalajara?",
|
| 100 |
+
"query": "SELECT \"Descripcion\", SUM(\"Cantidad\") AS total_vendido\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nAND \"Ciudad\" LIKE '%Guadalajara%'\nGROUP BY \"Descripcion\"\nORDER BY total_vendido DESC;"
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"pregunta": "Lista de productos más vendidos por ciudad",
|
| 104 |
+
"query": "SELECT \"Ciudad\", \"Descripcion\", SUM(\"Cantidad\") AS total_vendido\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nAND \"Ciudad\" IS NOT NULL\nGROUP BY \"Ciudad\", \"Descripcion\"\nORDER BY \"Ciudad\", total_vendido DESC;"
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"pregunta": "Qué producto se vendió más en la ciudad de Zapopan?",
|
| 108 |
+
"query": "SELECT \"Descripcion\", SUM(\"Cantidad\") AS total_vendido\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nAND \"Ciudad\" LIKE '%Zapopan%'\nGROUP BY \"Descripcion\"\nORDER BY total_vendido DESC\nLIMIT 1;"
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"pregunta": "Productos con mayor cantidad vendida en Guadalajara",
|
| 112 |
+
"query": "SELECT \"Descripcion\", SUM(\"Cantidad\") AS total_vendido\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nAND \"Ciudad\" LIKE '%Guadalajara%'\nGROUP BY \"Descripcion\"\nORDER BY total_vendido DESC;"
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"pregunta": "Top 5 productos por ventas en la ciudad de Colima",
|
| 116 |
+
"query": "SELECT \"Descripcion\", SUM(\"Cantidad\") AS total_vendido\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nAND \"Ciudad\" LIKE '%Colima%'\nGROUP BY \"Descripcion\"\nORDER BY total_vendido DESC\nLIMIT 5;"
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"pregunta": "Productos que más ingresos generaron en Tepic",
|
| 120 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nAND \"Ciudad\" LIKE '%Tepic%'\nGROUP BY \"Descripcion\"\nORDER BY total_ingresos DESC;"
|
| 121 |
+
},
|
| 122 |
+
{
|
| 123 |
+
"pregunta": "Cuáles son los productos más populares en la ciudad de Vallarta?",
|
| 124 |
+
"query": "SELECT \"Descripcion\", SUM(\"Cantidad\") AS total_vendido\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nAND \"Ciudad\" LIKE '%Vallarta%'\nGROUP BY \"Descripcion\"\nORDER BY total_vendido DESC;"
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"pregunta": "Ranking de ventas de productos por ciudad",
|
| 128 |
+
"query": "SELECT \"Ciudad\", \"Descripcion\", SUM(\"Cantidad\") AS total_vendido\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nAND \"Ciudad\" IS NOT NULL\nGROUP BY \"Ciudad\", \"Descripcion\"\nORDER BY \"Ciudad\", total_vendido DESC;"
|
| 129 |
+
},
|
| 130 |
+
{
|
| 131 |
+
"pregunta": "Producto más vendido en la ciudad de Planta",
|
| 132 |
+
"query": "SELECT \"Descripcion\", SUM(\"Cantidad\") AS total_vendido\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nAND \"Ciudad\" LIKE '%Planta%'\nGROUP BY \"Descripcion\"\nORDER BY total_vendido DESC\nLIMIT 1;"
|
| 133 |
+
},
|
| 134 |
+
{
|
| 135 |
+
"pregunta": "Dame los productos que más se vendieron en Guadalajara",
|
| 136 |
+
"query": "SELECT \"Descripcion\", SUM(\"Cantidad\") AS total_vendido\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nAND \"Ciudad\" LIKE '%Guadalajara%'\nGROUP BY \"Descripcion\"\nORDER BY total_vendido DESC;"
|
| 137 |
+
}
|
| 138 |
+
]
|
| 139 |
+
},
|
| 140 |
+
"CLIENTE_CIUDAD": {
|
| 141 |
+
"rules": [
|
| 142 |
+
"Usar siempre nombres exactos de columnas",
|
| 143 |
+
"Usar solo las columnas listadas",
|
| 144 |
+
"Prohibido inventar columnas",
|
| 145 |
+
"Para clientes usar la columna 'Razon Social'",
|
| 146 |
+
"Para ciudad usar SIEMPRE la columna 'Ciudad' con LIKE",
|
| 147 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 148 |
+
"Para cantidades usar SUM(\"Cantidad\"), para dinero usar SUM(\"Neto\")",
|
| 149 |
+
"Agrupar siempre por la dimensión principal (cliente o ciudad) al usar agregaciones",
|
| 150 |
+
"Ordenar DESC para 'más/mayor', ASC para 'menos/menor'",
|
| 151 |
+
"Para filtrar por mes usar: strftime('%m', \"Fecha\") = 'MM'",
|
| 152 |
+
"Para fechas específicas usar DATE(\"Fecha\") con BETWEEN o <= según el caso",
|
| 153 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 154 |
+
"No usar acentos en la query",
|
| 155 |
+
"Si se compara un cliente específico o ciudad específica, usar comillas simples en el valor del WHERE"
|
| 156 |
+
],
|
| 157 |
+
"examples": [
|
| 158 |
+
{
|
| 159 |
+
"pregunta": "Clientes más valiosos por ciudad",
|
| 160 |
+
"query": "SELECT \"Ciudad\", \"Razon Social\", SUM(\"Neto\") AS total_compra\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Ciudad\" IS NOT NULL\nGROUP BY \"Ciudad\", \"Razon Social\"\nORDER BY \"Ciudad\", total_compra DESC;"
|
| 161 |
+
},
|
| 162 |
+
{
|
| 163 |
+
"pregunta": "Dame los clientes con mayor compra por ciudad",
|
| 164 |
+
"query": "SELECT \"Ciudad\", \"Razon Social\", SUM(\"Neto\") AS total_compra\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Ciudad\" IS NOT NULL\nGROUP BY \"Ciudad\", \"Razon Social\"\nORDER BY \"Ciudad\", total_compra DESC;"
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
"pregunta": "Clientes frecuentes en la ciudad",
|
| 168 |
+
"query": "SELECT \"Ciudad\", \"Razon Social\", COUNT(\"Descripcion\") AS total_compras\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Ciudad\" IS NOT NULL\nGROUP BY \"Ciudad\", \"Razon Social\"\nORDER BY \"Ciudad\", total_compras DESC;"
|
| 169 |
+
},
|
| 170 |
+
{
|
| 171 |
+
"pregunta": "Total de clientes por ciudad",
|
| 172 |
+
"query": "SELECT \"Ciudad\", COUNT(DISTINCT \"Razon Social\") AS total_clientes\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nGROUP BY \"Ciudad\"\nORDER BY \"Ciudad\";"
|
| 173 |
+
},
|
| 174 |
+
{
|
| 175 |
+
"pregunta": "Distribución de clientes activos por ciudad",
|
| 176 |
+
"query": "SELECT \"Ciudad\", COUNT(DISTINCT \"Razon Social\") AS total_clientes_activos\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND DATE(\"Fecha\") > DATE('now', '-28 day')\nGROUP BY \"Ciudad\"\nORDER BY \"Ciudad\";"
|
| 177 |
+
},
|
| 178 |
+
{
|
| 179 |
+
"pregunta": "Clientes que compran más en cada ciudad",
|
| 180 |
+
"query": "SELECT \"Ciudad\", \"Razon Social\", SUM(\"Cantidad\") AS total_unidades\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Ciudad\" IS NOT NULL\nGROUP BY \"Ciudad\", \"Razon Social\"\nORDER BY \"Ciudad\", total_unidades DESC;"
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"pregunta": "Lista de clientes por ciudad",
|
| 184 |
+
"query": "SELECT \"Ciudad\", \"Razon Social\"\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND \"Ciudad\" IS NOT NULL\nORDER BY \"Ciudad\", \"Razon Social\";"
|
| 185 |
+
},
|
| 186 |
+
{
|
| 187 |
+
"pregunta": "Cantidad de clientes por ciudad",
|
| 188 |
+
"query": "SELECT \"Ciudad\", COUNT(DISTINCT \"Razon Social\") AS total_clientes\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nGROUP BY \"Ciudad\"\nORDER BY total_clientes DESC;"
|
| 189 |
+
}
|
| 190 |
+
]
|
| 191 |
+
},
|
| 192 |
+
"PRODUCTO_DINERO": {
|
| 193 |
+
"rules": [
|
| 194 |
+
"Usar siempre nombres exactos de columnas",
|
| 195 |
+
"Usar solo las columnas listadas",
|
| 196 |
+
"Prohibido inventar columnas",
|
| 197 |
+
"Para productos usar la columna 'Descripcion'",
|
| 198 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 199 |
+
"Para dinero usar SUM(\"Neto\")",
|
| 200 |
+
"Agrupar siempre por la dimensión principal (producto o ciudad) al usar agregaciones",
|
| 201 |
+
"Ordenar DESC para 'más/mayor', ASC para 'menos/menor'",
|
| 202 |
+
"Para filtrar por mes usar: strftime('%m', \"Fecha\") = 'MM'",
|
| 203 |
+
"Para fechas específicas usar DATE(\"Fecha\") con BETWEEN o <= según el caso",
|
| 204 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 205 |
+
"No usar acentos en la query",
|
| 206 |
+
"Si se compara un producto específico o ciudad específica, usar comillas simples en el valor del WHERE"
|
| 207 |
+
],
|
| 208 |
+
"examples": [
|
| 209 |
+
{
|
| 210 |
+
"pregunta": "Productos que generan más ingresos",
|
| 211 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nGROUP BY \"Descripcion\"\nORDER BY total_ingresos DESC\nLIMIT 10;"
|
| 212 |
+
},
|
| 213 |
+
{
|
| 214 |
+
"pregunta": "Producto con mayores ventas en dinero",
|
| 215 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nGROUP BY \"Descripcion\"\nORDER BY total_ingresos DESC\nLIMIT 1;"
|
| 216 |
+
},
|
| 217 |
+
{
|
| 218 |
+
"pregunta": "Top productos por ingresos",
|
| 219 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nGROUP BY \"Descripcion\"\nORDER BY total_ingresos DESC\nLIMIT 5;"
|
| 220 |
+
},
|
| 221 |
+
{
|
| 222 |
+
"pregunta": "Ingresos totales por producto",
|
| 223 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nGROUP BY \"Descripcion\"\nORDER BY total_ingresos DESC;"
|
| 224 |
+
},
|
| 225 |
+
{
|
| 226 |
+
"pregunta": "Producto más rentable por unidad",
|
| 227 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\")/SUM(\"Cantidad\") AS ingreso_por_unidad\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nGROUP BY \"Descripcion\"\nORDER BY ingreso_por_unidad DESC\nLIMIT 1;"
|
| 228 |
+
},
|
| 229 |
+
{
|
| 230 |
+
"pregunta": "Rentabilidad de cada producto",
|
| 231 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\")/SUM(\"Cantidad\") AS ingreso_por_unidad\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nGROUP BY \"Descripcion\"\nORDER BY ingreso_por_unidad DESC;"
|
| 232 |
+
},
|
| 233 |
+
{
|
| 234 |
+
"pregunta": "Productos con mejor margen de ganancia",
|
| 235 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nGROUP BY \"Descripcion\"\nORDER BY total_ingresos DESC;"
|
| 236 |
+
},
|
| 237 |
+
{
|
| 238 |
+
"pregunta": "Ingresos generados por producto",
|
| 239 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nGROUP BY \"Descripcion\"\nORDER BY total_ingresos DESC;"
|
| 240 |
+
},
|
| 241 |
+
{
|
| 242 |
+
"pregunta": "Producto que más dinero genera",
|
| 243 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nGROUP BY \"Descripcion\"\nORDER BY total_ingresos DESC\nLIMIT 1;"
|
| 244 |
+
},
|
| 245 |
+
{
|
| 246 |
+
"pregunta": "Top 10 productos con mayores ingresos",
|
| 247 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nGROUP BY \"Descripcion\"\nORDER BY total_ingresos DESC\nLIMIT 10;"
|
| 248 |
+
},
|
| 249 |
+
{
|
| 250 |
+
"pregunta": "Ingresos por Queso Adobera",
|
| 251 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Descripcion\" LIKE '%Queso Adobera%'\nGROUP BY \"Descripcion\";"
|
| 252 |
+
},
|
| 253 |
+
{
|
| 254 |
+
"pregunta": "Rentabilidad del producto Aderezo Ranch",
|
| 255 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\")/SUM(\"Cantidad\") AS ingreso_por_unidad\nFROM \"{table_name}\"\nWHERE \"Descripcion\" LIKE '%Aderezo Ranch%'\nGROUP BY \"Descripcion\";"
|
| 256 |
+
},
|
| 257 |
+
{
|
| 258 |
+
"pregunta": "Cuánto dinero genera Caja Plástica",
|
| 259 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Descripcion\" LIKE '%Caja Plástica%'\nGROUP BY \"Descripcion\";"
|
| 260 |
+
}
|
| 261 |
+
]
|
| 262 |
+
},
|
| 263 |
+
"CIUDAD_DINERO": {
|
| 264 |
+
"rules": [
|
| 265 |
+
"Usar siempre nombres exactos de columnas",
|
| 266 |
+
"Usar solo las columnas listadas",
|
| 267 |
+
"Prohibido inventar columnas",
|
| 268 |
+
"Para ciudad usar la columna 'Ciudad'",
|
| 269 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 270 |
+
"Para dinero usar SUM(\"Neto\")",
|
| 271 |
+
"Agrupar siempre por la dimensión principal (Ciudad) al usar agregaciones",
|
| 272 |
+
"Ordenar DESC para 'más/mayor', ASC para 'menos/menor'",
|
| 273 |
+
"Para filtrar por mes usar: strftime('%m', \"Fecha\") = 'MM'",
|
| 274 |
+
"Para fechas específicas usar DATE(\"Fecha\") con BETWEEN o <= según el caso",
|
| 275 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 276 |
+
"No usar acentos en la query",
|
| 277 |
+
"Si se compara una ciudad específica, usar comillas simples en el valor del WHERE"
|
| 278 |
+
],
|
| 279 |
+
"examples": [
|
| 280 |
+
{
|
| 281 |
+
"pregunta": "Ciudades con mayor facturación",
|
| 282 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nGROUP BY \"Ciudad\"\nORDER BY total_ingresos DESC\nLIMIT 10;"
|
| 283 |
+
},
|
| 284 |
+
{
|
| 285 |
+
"pregunta": "Ciudad con más ingresos en el último mes",
|
| 286 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL AND strftime('%m', \"Fecha\") = '08'\nGROUP BY \"Ciudad\"\nORDER BY total_ingresos DESC\nLIMIT 1;"
|
| 287 |
+
},
|
| 288 |
+
{
|
| 289 |
+
"pregunta": "Total de dinero generado por ciudad",
|
| 290 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nGROUP BY \"Ciudad\"\nORDER BY total_ingresos DESC;"
|
| 291 |
+
},
|
| 292 |
+
{
|
| 293 |
+
"pregunta": "Ingresos totales por ciudad",
|
| 294 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nGROUP BY \"Ciudad\"\nORDER BY total_ingresos DESC;"
|
| 295 |
+
},
|
| 296 |
+
{
|
| 297 |
+
"pregunta": "Ticket promedio por ciudad",
|
| 298 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\")/COUNT(DISTINCT \"Razon Social\") AS ticket_promedio\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nGROUP BY \"Ciudad\"\nORDER BY ticket_promedio DESC;"
|
| 299 |
+
},
|
| 300 |
+
{
|
| 301 |
+
"pregunta": "Ciudad con mayor ticket promedio",
|
| 302 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\")/COUNT(DISTINCT \"Razon Social\") AS ticket_promedio\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nGROUP BY \"Ciudad\"\nORDER BY ticket_promedio DESC\nLIMIT 1;"
|
| 303 |
+
},
|
| 304 |
+
{
|
| 305 |
+
"pregunta": "Ingresos generados en Guadalajara",
|
| 306 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Ciudad\" LIKE '%Guadalajara%'\nGROUP BY \"Ciudad\";"
|
| 307 |
+
},
|
| 308 |
+
{
|
| 309 |
+
"pregunta": "Ingresos generados en Zapopan",
|
| 310 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Ciudad\" LIKE '%Zapopan%'\nGROUP BY \"Ciudad\";"
|
| 311 |
+
},
|
| 312 |
+
{
|
| 313 |
+
"pregunta": "Ingresos totales en Colima",
|
| 314 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Ciudad\" LIKE '%Colima%'\nGROUP BY \"Ciudad\";"
|
| 315 |
+
},
|
| 316 |
+
{
|
| 317 |
+
"pregunta": "Ventas totales en Tepic",
|
| 318 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Ciudad\" LIKE '%Tepic%'\nGROUP BY \"Ciudad\";"
|
| 319 |
+
},
|
| 320 |
+
{
|
| 321 |
+
"pregunta": "Crecimiento de ingresos en Vallarta",
|
| 322 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Ciudad\" LIKE '%Vallarta%'\nGROUP BY \"Ciudad\";"
|
| 323 |
+
},
|
| 324 |
+
{
|
| 325 |
+
"pregunta": "Dinero generado por productos en Planta",
|
| 326 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Ciudad\" LIKE '%Planta%'\nGROUP BY \"Ciudad\";"
|
| 327 |
+
},
|
| 328 |
+
{
|
| 329 |
+
"pregunta": "Ciudad que más dinero genera",
|
| 330 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nGROUP BY \"Ciudad\"\nORDER BY total_ingresos DESC\nLIMIT 1;"
|
| 331 |
+
},
|
| 332 |
+
{
|
| 333 |
+
"pregunta": "Ingresos de Guadalajara por ventas",
|
| 334 |
+
"query": "SELECT \"Ciudad\", SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\"\nWHERE \"Ciudad\" LIKE '%Guadalajara%'\nGROUP BY \"Ciudad\";"
|
| 335 |
+
}
|
| 336 |
+
]
|
| 337 |
+
},
|
| 338 |
+
"CLIENTE_DINERO": {
|
| 339 |
+
"rules": [
|
| 340 |
+
"Usar siempre nombres exactos de columnas",
|
| 341 |
+
"Usar solo las columnas listadas",
|
| 342 |
+
"Prohibido inventar columnas",
|
| 343 |
+
"Para cliente usar la columna 'Razon Social'",
|
| 344 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 345 |
+
"Para dinero usar SUM(\"Neto\")",
|
| 346 |
+
"Agrupar siempre por la dimensión principal (Razon Social) al usar agregaciones",
|
| 347 |
+
"Ordenar DESC para 'más/mayor', ASC para 'menos/menor'",
|
| 348 |
+
"Para filtrar por mes usar: strftime('%m', \"Fecha\") = 'MM'",
|
| 349 |
+
"Para fechas específicas usar DATE(\"Fecha\") con BETWEEN o <= según el caso",
|
| 350 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 351 |
+
"No usar acentos en la query",
|
| 352 |
+
"Si se compara un cliente específico, usar comillas simples en el valor del WHERE"
|
| 353 |
+
],
|
| 354 |
+
"examples": [
|
| 355 |
+
{
|
| 356 |
+
"pregunta": "Top clientes por valor de compras",
|
| 357 |
+
"query": "SELECT \"Razon Social\", SUM(\"Neto\") AS total_gastado\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nGROUP BY \"Razon Social\"\nORDER BY total_gastado DESC\nLIMIT 10;"
|
| 358 |
+
},
|
| 359 |
+
{
|
| 360 |
+
"pregunta": "Clientes que más dinero han gastado",
|
| 361 |
+
"query": "SELECT \"Razon Social\", SUM(\"Neto\") AS total_gastado\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nGROUP BY \"Razon Social\"\nORDER BY total_gastado DESC\nLIMIT 10;"
|
| 362 |
+
},
|
| 363 |
+
{
|
| 364 |
+
"pregunta": "Clientes con mayor ticket promedio",
|
| 365 |
+
"query": "SELECT \"Razon Social\", SUM(\"Neto\")/COUNT(DISTINCT DATE(\"Fecha\")) AS ticket_promedio\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nGROUP BY \"Razon Social\"\nORDER BY ticket_promedio DESC\nLIMIT 10;"
|
| 366 |
+
},
|
| 367 |
+
{
|
| 368 |
+
"pregunta": "Total de dinero gastado por cliente",
|
| 369 |
+
"query": "SELECT \"Razon Social\", SUM(\"Neto\") AS total_gastado\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nGROUP BY \"Razon Social\"\nORDER BY total_gastado DESC;"
|
| 370 |
+
},
|
| 371 |
+
{
|
| 372 |
+
"pregunta": "Clientes con compras de alto valor",
|
| 373 |
+
"query": "SELECT \"Razon Social\", SUM(\"Neto\") AS total_gastado\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL AND SUM(\"Neto\") > 1000\nGROUP BY \"Razon Social\"\nORDER BY total_gastado DESC;"
|
| 374 |
+
},
|
| 375 |
+
{
|
| 376 |
+
"pregunta": "Clientes con mayor frecuencia de compra",
|
| 377 |
+
"query": "SELECT \"Razon Social\", COUNT(DISTINCT DATE(\"Fecha\")) AS frecuencia\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nGROUP BY \"Razon Social\"\nORDER BY frecuencia DESC\nLIMIT 10;"
|
| 378 |
+
},
|
| 379 |
+
{
|
| 380 |
+
"pregunta": "Clientes con mayor potencial de crecimiento",
|
| 381 |
+
"query": "SELECT \"Razon Social\", SUM(\"Neto\") AS total_gastado, COUNT(DISTINCT DATE(\"Fecha\")) AS frecuencia\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nGROUP BY \"Razon Social\"\nORDER BY total_gastado DESC, frecuencia DESC\nLIMIT 10;"
|
| 382 |
+
},
|
| 383 |
+
{
|
| 384 |
+
"pregunta": "Valor total de compras por cliente",
|
| 385 |
+
"query": "SELECT \"Razon Social\", SUM(\"Neto\") AS total_gastado\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nGROUP BY \"Razon Social\";"
|
| 386 |
+
},
|
| 387 |
+
{
|
| 388 |
+
"pregunta": "Clientes que más contribuyen a los ingresos",
|
| 389 |
+
"query": "SELECT \"Razon Social\", SUM(\"Neto\") AS total_gastado\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nGROUP BY \"Razon Social\"\nORDER BY total_gastado DESC\nLIMIT 10;"
|
| 390 |
+
},
|
| 391 |
+
{
|
| 392 |
+
"pregunta": "Clientes con mayores ingresos acumulados",
|
| 393 |
+
"query": "SELECT \"Razon Social\", SUM(\"Neto\") AS total_gastado\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nGROUP BY \"Razon Social\"\nORDER BY total_gastado DESC;"
|
| 394 |
+
},
|
| 395 |
+
{
|
| 396 |
+
"pregunta": "Clientes con compras recientes de alto valor",
|
| 397 |
+
"query": "SELECT \"Razon Social\", SUM(\"Neto\") AS total_gastado\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL AND DATE(\"Fecha\") > DATE('now','-30 day')\nGROUP BY \"Razon Social\"\nORDER BY total_gastado DESC\nLIMIT 10;"
|
| 398 |
+
},
|
| 399 |
+
{
|
| 400 |
+
"pregunta": "Clientes más valiosos en el último mes",
|
| 401 |
+
"query": "SELECT \"Razon Social\", SUM(\"Neto\") AS total_gastado\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL AND strftime('%m', \"Fecha\") = '08'\nGROUP BY \"Razon Social\"\nORDER BY total_gastado DESC\nLIMIT 10;"
|
| 402 |
+
}
|
| 403 |
+
]
|
| 404 |
+
},
|
| 405 |
+
"TIEMPO_DINERO": {
|
| 406 |
+
"rules": [
|
| 407 |
+
"Usar siempre nombres exactos de columnas",
|
| 408 |
+
"Usar solo las columnas listadas",
|
| 409 |
+
"Prohibido inventar columnas",
|
| 410 |
+
"Para dinero usar SUM(\"Neto\")",
|
| 411 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 412 |
+
"Para fechas usar la columna \"Fecha\" con DATE() o strftime() según corresponda",
|
| 413 |
+
"Agrupar por la dimensión temporal adecuada (día, semana, mes, año) al usar agregaciones",
|
| 414 |
+
"Ordenar DESC para 'más/mayor', ASC para 'menos/menor'",
|
| 415 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 416 |
+
"No usar acentos en la query",
|
| 417 |
+
"Para comparativas usar BETWEEN o filtros de rango en DATE(\"Fecha\")",
|
| 418 |
+
"Si se filtra por mes usar strftime('%m', \"Fecha\") = 'MM'",
|
| 419 |
+
"Si se filtra por año usar strftime('%Y', \"Fecha\") = 'YYYY'"
|
| 420 |
+
],
|
| 421 |
+
"examples": [
|
| 422 |
+
{
|
| 423 |
+
"pregunta": "¿Cuánto vendimos este mes?",
|
| 424 |
+
"query": "SELECT SUM(\"Neto\") AS total_ventas_mes\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL AND strftime('%m', \"Fecha\") = '08';"
|
| 425 |
+
},
|
| 426 |
+
{
|
| 427 |
+
"pregunta": "¿Cuál fue el mes con mayores ventas este año?",
|
| 428 |
+
"query": "SELECT strftime('%m', \"Fecha\") AS mes, SUM(\"Neto\") AS total_ventas\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL AND strftime('%Y', \"Fecha\") = '2025'\nGROUP BY mes\nORDER BY total_ventas DESC\nLIMIT 1;"
|
| 429 |
+
},
|
| 430 |
+
{
|
| 431 |
+
"pregunta": "¿Cuánto generamos en ingresos en junio?",
|
| 432 |
+
"query": "SELECT SUM(\"Neto\") AS total_junio\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL AND strftime('%m', \"Fecha\") = '06';"
|
| 433 |
+
},
|
| 434 |
+
{
|
| 435 |
+
"pregunta": "¿Cuál es la tendencia de ventas mensuales?",
|
| 436 |
+
"query": "SELECT strftime('%m', \"Fecha\") AS mes, SUM(\"Neto\") AS total_ventas\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL\nGROUP BY mes\nORDER BY mes ASC;"
|
| 437 |
+
},
|
| 438 |
+
{
|
| 439 |
+
"pregunta": "Ventas por día de la semana",
|
| 440 |
+
"query": "SELECT strftime('%w', \"Fecha\") AS dia_semana, SUM(\"Neto\") AS total_ventas\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL\nGROUP BY dia_semana\nORDER BY dia_semana ASC;"
|
| 441 |
+
},
|
| 442 |
+
{
|
| 443 |
+
"pregunta": "Promedio de ventas diarias",
|
| 444 |
+
"query": "SELECT DATE(\"Fecha\") AS dia, AVG(\"Neto\") AS promedio_diario\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL\nGROUP BY dia\nORDER BY dia ASC;"
|
| 445 |
+
},
|
| 446 |
+
{
|
| 447 |
+
"pregunta": "¿Cuánto se vendió el lunes pasado?",
|
| 448 |
+
"query": "SELECT SUM(\"Neto\") AS total_lunes\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL AND strftime('%w', \"Fecha\") = '1' AND DATE(\"Fecha\") BETWEEN DATE('now','-7 day') AND DATE('now');"
|
| 449 |
+
},
|
| 450 |
+
{
|
| 451 |
+
"pregunta": "¿Cuál fue el día con más ingresos este mes?",
|
| 452 |
+
"query": "SELECT DATE(\"Fecha\") AS dia, SUM(\"Neto\") AS total_ventas\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL AND strftime('%m', \"Fecha\") = '08'\nGROUP BY dia\nORDER BY total_ventas DESC\nLIMIT 1;"
|
| 453 |
+
},
|
| 454 |
+
{
|
| 455 |
+
"pregunta": "Total de ventas acumuladas por mes",
|
| 456 |
+
"query": "SELECT strftime('%m', \"Fecha\") AS mes, SUM(\"Neto\") AS total_ventas\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL\nGROUP BY mes\nORDER BY mes ASC;"
|
| 457 |
+
},
|
| 458 |
+
{
|
| 459 |
+
"pregunta": "¿Cuánto crecieron nuestras ventas comparando mayo y junio?",
|
| 460 |
+
"query": "SELECT strftime('%m', \"Fecha\") AS mes, SUM(\"Neto\") AS total_ventas\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL AND strftime('%m', \"Fecha\") IN ('05','06')\nGROUP BY mes\nORDER BY mes ASC;"
|
| 461 |
+
},
|
| 462 |
+
{
|
| 463 |
+
"pregunta": "Ventas semanales del mes actual",
|
| 464 |
+
"query": "SELECT strftime('%W', \"Fecha\") AS semana, SUM(\"Neto\") AS total_ventas\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL AND strftime('%m', \"Fecha\") = strftime('%m','now')\nGROUP BY semana\nORDER BY semana ASC;"
|
| 465 |
+
},
|
| 466 |
+
{
|
| 467 |
+
"pregunta": "¿Cuánto facturamos en la última semana?",
|
| 468 |
+
"query": "SELECT SUM(\"Neto\") AS total_ventas_semana\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL AND DATE(\"Fecha\") BETWEEN DATE('now','-7 day') AND DATE('now');"
|
| 469 |
+
},
|
| 470 |
+
{
|
| 471 |
+
"pregunta": "Crecimiento interanual de ventas",
|
| 472 |
+
"query": "SELECT strftime('%Y', \"Fecha\") AS anio, SUM(\"Neto\") AS total_ventas\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL\nGROUP BY anio\nORDER BY anio ASC;"
|
| 473 |
+
},
|
| 474 |
+
{
|
| 475 |
+
"pregunta": "Comparativa de ingresos entre años",
|
| 476 |
+
"query": "SELECT strftime('%Y', \"Fecha\") AS anio, SUM(\"Neto\") AS total_ventas\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL\nGROUP BY anio\nORDER BY anio ASC;"
|
| 477 |
+
},
|
| 478 |
+
{
|
| 479 |
+
"pregunta": "Ingresos generados por mes",
|
| 480 |
+
"query": "SELECT strftime('%m', \"Fecha\") AS mes, SUM(\"Neto\") AS total_ventas\nFROM \"{table_name}\"\nWHERE \"Neto\" IS NOT NULL\nGROUP BY mes\nORDER BY mes ASC;"
|
| 481 |
+
}
|
| 482 |
+
]
|
| 483 |
+
},
|
| 484 |
+
"CIUDADES": {
|
| 485 |
+
"rules": [
|
| 486 |
+
"Usar siempre nombres exactos de columnas",
|
| 487 |
+
"Usar solo las columnas listadas",
|
| 488 |
+
"Prohibido inventar columnas",
|
| 489 |
+
"Para ciudad usar SIEMPRE la columna 'Ciudad'",
|
| 490 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 491 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 492 |
+
"No usar acentos en la query",
|
| 493 |
+
"Agrupar siempre por 'Ciudad' cuando se requiera contar o listar",
|
| 494 |
+
"Si se pide un listado, usar DISTINCT para evitar duplicados"
|
| 495 |
+
],
|
| 496 |
+
"examples": [
|
| 497 |
+
{
|
| 498 |
+
"pregunta": "¿Cuántas ciudades diferentes tenemos registradas?",
|
| 499 |
+
"query": "SELECT COUNT(DISTINCT \"Ciudad\") AS total_ciudades\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL;"
|
| 500 |
+
},
|
| 501 |
+
{
|
| 502 |
+
"pregunta": "Lista de todas las ciudades registradas",
|
| 503 |
+
"query": "SELECT DISTINCT \"Ciudad\"\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nORDER BY \"Ciudad\" ASC;"
|
| 504 |
+
},
|
| 505 |
+
{
|
| 506 |
+
"pregunta": "¿Cuáles son las ciudades que tenemos en la base?",
|
| 507 |
+
"query": "SELECT DISTINCT \"Ciudad\"\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nORDER BY \"Ciudad\" ASC;"
|
| 508 |
+
},
|
| 509 |
+
{
|
| 510 |
+
"pregunta": "Nombra las ciudades únicas",
|
| 511 |
+
"query": "SELECT DISTINCT \"Ciudad\"\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nORDER BY \"Ciudad\" ASC;"
|
| 512 |
+
},
|
| 513 |
+
{
|
| 514 |
+
"pregunta": "Dame un listado de ciudades",
|
| 515 |
+
"query": "SELECT DISTINCT \"Ciudad\"\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nORDER BY \"Ciudad\" ASC;"
|
| 516 |
+
},
|
| 517 |
+
{
|
| 518 |
+
"pregunta": "¿Cuántas ciudades distintas aparecen en nuestra base?",
|
| 519 |
+
"query": "SELECT COUNT(DISTINCT \"Ciudad\") AS total_ciudades\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL;"
|
| 520 |
+
},
|
| 521 |
+
{
|
| 522 |
+
"pregunta": "Muestra las ciudades disponibles",
|
| 523 |
+
"query": "SELECT DISTINCT \"Ciudad\"\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nORDER BY \"Ciudad\" ASC;"
|
| 524 |
+
},
|
| 525 |
+
{
|
| 526 |
+
"pregunta": "Listado de ciudades al azar",
|
| 527 |
+
"query": "SELECT DISTINCT \"Ciudad\"\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nORDER BY RANDOM();"
|
| 528 |
+
},
|
| 529 |
+
{
|
| 530 |
+
"pregunta": "¿Cuáles son las ciudades registradas?",
|
| 531 |
+
"query": "SELECT DISTINCT \"Ciudad\"\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nORDER BY \"Ciudad\" ASC;"
|
| 532 |
+
},
|
| 533 |
+
{
|
| 534 |
+
"pregunta": "Ciudades únicas de nuestra base",
|
| 535 |
+
"query": "SELECT DISTINCT \"Ciudad\"\nFROM \"{table_name}\"\nWHERE \"Ciudad\" IS NOT NULL\nORDER BY \"Ciudad\" ASC;"
|
| 536 |
+
}
|
| 537 |
+
]
|
| 538 |
+
},
|
| 539 |
+
"CLIENTES": {
|
| 540 |
+
"rules": [
|
| 541 |
+
"Usar siempre nombres exactos de columnas",
|
| 542 |
+
"Usar solo las columnas listadas",
|
| 543 |
+
"Prohibido inventar columnas",
|
| 544 |
+
"Para el nombre del cliente usar SIEMPRE 'Razon Social'",
|
| 545 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 546 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 547 |
+
"No usar acentos en la query",
|
| 548 |
+
"Agrupar siempre por 'Razon Social' cuando se requiera contar o listar",
|
| 549 |
+
"Si se pide un listado, usar DISTINCT para evitar duplicados"
|
| 550 |
+
],
|
| 551 |
+
"examples": [
|
| 552 |
+
{
|
| 553 |
+
"pregunta": "¿Cuántos clientes diferentes tenemos registrados?",
|
| 554 |
+
"query": "SELECT COUNT(DISTINCT \"Razon Social\") AS total_clientes\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL;"
|
| 555 |
+
},
|
| 556 |
+
{
|
| 557 |
+
"pregunta": "Lista de todos los clientes registrados",
|
| 558 |
+
"query": "SELECT DISTINCT \"Razon Social\"\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nORDER BY \"Razon Social\" ASC;"
|
| 559 |
+
},
|
| 560 |
+
{
|
| 561 |
+
"pregunta": "¿Cuáles son los clientes que tenemos en la base?",
|
| 562 |
+
"query": "SELECT DISTINCT \"Razon Social\"\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nORDER BY \"Razon Social\" ASC;"
|
| 563 |
+
},
|
| 564 |
+
{
|
| 565 |
+
"pregunta": "Nombra los clientes únicos",
|
| 566 |
+
"query": "SELECT DISTINCT \"Razon Social\"\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nORDER BY \"Razon Social\" ASC;"
|
| 567 |
+
},
|
| 568 |
+
{
|
| 569 |
+
"pregunta": "Dame un listado de clientes",
|
| 570 |
+
"query": "SELECT DISTINCT \"Razon Social\"\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nORDER BY \"Razon Social\" ASC;"
|
| 571 |
+
},
|
| 572 |
+
{
|
| 573 |
+
"pregunta": "¿Cuántos clientes distintos aparecen en nuestra base?",
|
| 574 |
+
"query": "SELECT COUNT(DISTINCT \"Razon Social\") AS total_clientes\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL;"
|
| 575 |
+
},
|
| 576 |
+
{
|
| 577 |
+
"pregunta": "Muestra los clientes disponibles",
|
| 578 |
+
"query": "SELECT DISTINCT \"Razon Social\"\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nORDER BY \"Razon Social\" ASC;"
|
| 579 |
+
},
|
| 580 |
+
{
|
| 581 |
+
"pregunta": "Listado de clientes al azar",
|
| 582 |
+
"query": "SELECT DISTINCT \"Razon Social\"\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nORDER BY RANDOM();"
|
| 583 |
+
},
|
| 584 |
+
{
|
| 585 |
+
"pregunta": "¿Cuáles son los clientes registrados?",
|
| 586 |
+
"query": "SELECT DISTINCT \"Razon Social\"\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nORDER BY \"Razon Social\" ASC;"
|
| 587 |
+
},
|
| 588 |
+
{
|
| 589 |
+
"pregunta": "Clientes únicos de nuestra base",
|
| 590 |
+
"query": "SELECT DISTINCT \"Razon Social\"\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nORDER BY \"Razon Social\" ASC;"
|
| 591 |
+
}
|
| 592 |
+
]
|
| 593 |
+
},
|
| 594 |
+
"VENTAS": {
|
| 595 |
+
"rules": [
|
| 596 |
+
"Usar siempre nombres exactos de columnas",
|
| 597 |
+
"Usar solo las columnas listadas",
|
| 598 |
+
"Prohibido inventar columnas",
|
| 599 |
+
"Para fechas usar siempre la columna 'Fecha' con DATE o strftime según corresponda",
|
| 600 |
+
"Para el cliente usar SIEMPRE 'Razon Social'",
|
| 601 |
+
"Para cantidades usar SUM(\"Cantidad\"), para dinero usar SUM(\"Neto\")",
|
| 602 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 603 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 604 |
+
"No usar acentos en la query",
|
| 605 |
+
"Agrupar siempre por la columna adecuada cuando se use una función de agregación",
|
| 606 |
+
"Para promedios usar AVG() según corresponda"
|
| 607 |
+
],
|
| 608 |
+
"examples": [
|
| 609 |
+
{
|
| 610 |
+
"pregunta": "¿Desde cuándo tenemos registros de ventas?",
|
| 611 |
+
"query": "SELECT MIN(DATE(\"Fecha\")) AS primera_fecha\nFROM \"{table_name}\";"
|
| 612 |
+
},
|
| 613 |
+
{
|
| 614 |
+
"pregunta": "¿Cuál es la primera fecha con ventas registradas?",
|
| 615 |
+
"query": "SELECT MIN(DATE(\"Fecha\")) AS primera_fecha\nFROM \"{table_name}\";"
|
| 616 |
+
},
|
| 617 |
+
{
|
| 618 |
+
"pregunta": "¿Cuál es la última fecha con ventas registradas?",
|
| 619 |
+
"query": "SELECT MAX(DATE(\"Fecha\")) AS ultima_fecha\nFROM \"{table_name}\";"
|
| 620 |
+
},
|
| 621 |
+
{
|
| 622 |
+
"pregunta": "Rango de fechas de nuestro historial de ventas",
|
| 623 |
+
"query": "SELECT MIN(DATE(\"Fecha\")) AS inicio, MAX(DATE(\"Fecha\")) AS fin\nFROM \"{table_name}\";"
|
| 624 |
+
},
|
| 625 |
+
{
|
| 626 |
+
"pregunta": "¿Cuántos días diferentes con ventas tenemos?",
|
| 627 |
+
"query": "SELECT COUNT(DISTINCT DATE(\"Fecha\")) AS dias_venta\nFROM \"{table_name}\";"
|
| 628 |
+
},
|
| 629 |
+
{
|
| 630 |
+
"pregunta": "Número total de días con actividad de ventas",
|
| 631 |
+
"query": "SELECT COUNT(DISTINCT DATE(\"Fecha\")) AS dias_activos\nFROM \"{table_name}\";"
|
| 632 |
+
},
|
| 633 |
+
{
|
| 634 |
+
"pregunta": "¿Cuántas transacciones totales se han registrado?",
|
| 635 |
+
"query": "SELECT COUNT(*) AS total_transacciones\nFROM \"{table_name}\";"
|
| 636 |
+
},
|
| 637 |
+
{
|
| 638 |
+
"pregunta": "Total de ventas realizadas hasta la fecha",
|
| 639 |
+
"query": "SELECT SUM(\"Cantidad\") AS total_unidades, SUM(\"Neto\") AS total_ingresos\nFROM \"{table_name}\";"
|
| 640 |
+
},
|
| 641 |
+
{
|
| 642 |
+
"pregunta": "Promedio de ventas por día",
|
| 643 |
+
"query": "SELECT AVG(dia_total) AS promedio_diario\nFROM (SELECT DATE(\"Fecha\") AS dia, SUM(\"Neto\") AS dia_total FROM \"{table_name}\" GROUP BY DATE(\"Fecha\"));"
|
| 644 |
+
},
|
| 645 |
+
{
|
| 646 |
+
"pregunta": "Valor promedio de ventas diarias",
|
| 647 |
+
"query": "SELECT AVG(dia_total) AS promedio_diario\nFROM (SELECT DATE(\"Fecha\") AS dia, SUM(\"Neto\") AS dia_total FROM \"{table_name}\" GROUP BY DATE(\"Fecha\"));"
|
| 648 |
+
},
|
| 649 |
+
{
|
| 650 |
+
"pregunta": "Día con mayor número de transacciones",
|
| 651 |
+
"query": "SELECT DATE(\"Fecha\") AS dia, COUNT(*) AS transacciones\nFROM \"{table_name}\"\nGROUP BY DATE(\"Fecha\")\nORDER BY transacciones DESC\nLIMIT 1;"
|
| 652 |
+
},
|
| 653 |
+
{
|
| 654 |
+
"pregunta": "Día con menor número de transacciones",
|
| 655 |
+
"query": "SELECT DATE(\"Fecha\") AS dia, COUNT(*) AS transacciones\nFROM \"{table_name}\"\nGROUP BY DATE(\"Fecha\")\nORDER BY transacciones ASC\nLIMIT 1;"
|
| 656 |
+
},
|
| 657 |
+
{
|
| 658 |
+
"pregunta": "Valor promedio de una venta",
|
| 659 |
+
"query": "SELECT AVG(\"Neto\") AS promedio_venta\nFROM \"{table_name}\";"
|
| 660 |
+
},
|
| 661 |
+
{
|
| 662 |
+
"pregunta": "Cantidad promedio de productos por venta",
|
| 663 |
+
"query": "SELECT AVG(\"Cantidad\") AS promedio_productos\nFROM \"{table_name}\";"
|
| 664 |
+
},
|
| 665 |
+
{
|
| 666 |
+
"pregunta": "Valor máximo de una venta registrada",
|
| 667 |
+
"query": "SELECT MAX(\"Neto\") AS venta_maxima\nFROM \"{table_name}\";"
|
| 668 |
+
}
|
| 669 |
+
]
|
| 670 |
+
},
|
| 671 |
+
"PRODUCTOS": {
|
| 672 |
+
"rules": [
|
| 673 |
+
"Usar siempre nombres exactos de columnas",
|
| 674 |
+
"Usar solo las columnas listadas",
|
| 675 |
+
"Prohibido inventar columnas",
|
| 676 |
+
"Para el nombre del cliente usar SIEMPRE 'Razon Social'",
|
| 677 |
+
"Para un mes específico usar: strftime('%m', \"Fecha\") = 'MM'",
|
| 678 |
+
"Para cantidades usar SUM(\"Cantidad\"), para dinero usar SUM(\"Neto\")",
|
| 679 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 680 |
+
"Ordenar DESC para 'más/mayor', ASC para 'menos/menor'",
|
| 681 |
+
"Usar LIKE para búsquedas de producto",
|
| 682 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 683 |
+
"No usar acentos en la query",
|
| 684 |
+
"Agrupar siempre por la columna adecuada cuando se use una función de agregación",
|
| 685 |
+
"Si se compara un producto específico, usar comillas simples en el valor del WHERE"
|
| 686 |
+
],
|
| 687 |
+
"examples": [
|
| 688 |
+
{
|
| 689 |
+
"pregunta": "Top 10 productos más vendidos",
|
| 690 |
+
"query": "SELECT \"Descripcion\", SUM(\"Cantidad\") AS total_vendido\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nGROUP BY \"Descripcion\"\nORDER BY total_vendido DESC\nLIMIT 10;"
|
| 691 |
+
},
|
| 692 |
+
{
|
| 693 |
+
"pregunta": "Producto con mayor valor neto",
|
| 694 |
+
"query": "SELECT \"Descripcion\", SUM(\"Neto\") AS valor_total\nFROM \"{table_name}\"\nWHERE \"Descripcion\" IS NOT NULL\nGROUP BY \"Descripcion\"\nORDER BY valor_total DESC\nLIMIT 1;"
|
| 695 |
+
},
|
| 696 |
+
{
|
| 697 |
+
"pregunta": "¿En qué ciudad es más comprado el producto Queso Gouda Importado Chileno Colun?",
|
| 698 |
+
"query": "SELECT \"Descripcion\", \"Ciudad\", SUM(\"Cantidad\") AS total_vendido\nFROM \"{table_name}\"\nWHERE \"Descripcion\" LIKE '%Queso Gouda%' AND \"Cliente\" IS NOT NULL\nGROUP BY \"Ciudad\"\nORDER BY total_vendido DESC\nLIMIT 1;"
|
| 699 |
+
}
|
| 700 |
+
]
|
| 701 |
+
},
|
| 702 |
+
"CLIENTES_CERO_TIEMPO": {
|
| 703 |
+
"rules": [
|
| 704 |
+
"Usar siempre nombres exactos de columnas",
|
| 705 |
+
"Usar solo las columnas listadas",
|
| 706 |
+
"Prohibido inventar columnas",
|
| 707 |
+
"Para el nombre del cliente usar SIEMPRE 'Razon Social'",
|
| 708 |
+
"Siempre excluir valores nulos con IS NOT NULL en las columnas usadas",
|
| 709 |
+
"Un cliente cero es aquel que NO tiene compras en las últimas 4 semanas",
|
| 710 |
+
"Para filtrar por mes usar: strftime('%m', \"Fecha\") = 'MM'",
|
| 711 |
+
"Para filtrar por trimestre usar BETWEEN con las fechas correspondientes",
|
| 712 |
+
"Contestar siempre en el idioma de la pregunta",
|
| 713 |
+
"No usar acentos en la query",
|
| 714 |
+
"Agrupar siempre por la columna adecuada cuando se use una función de agregación"
|
| 715 |
+
],
|
| 716 |
+
"examples": [
|
| 717 |
+
{
|
| 718 |
+
"pregunta": "¿Cuántos clientes cero tuvimos en enero?",
|
| 719 |
+
"query": "SELECT COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND strftime('%m', \"Fecha\") = '01'\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('2025-01-31', '-27 day')\n);"
|
| 720 |
+
},
|
| 721 |
+
{
|
| 722 |
+
"pregunta": "Dame el total de clientes cero en febrero",
|
| 723 |
+
"query": "SELECT COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND strftime('%m', \"Fecha\") = '02'\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('2025-02-28', '-27 day')\n);"
|
| 724 |
+
},
|
| 725 |
+
{
|
| 726 |
+
"pregunta": "Clientes cero correspondientes a abril",
|
| 727 |
+
"query": "SELECT COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND strftime('%m', \"Fecha\") = '04'\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('2025-04-30', '-27 day')\n);"
|
| 728 |
+
},
|
| 729 |
+
{
|
| 730 |
+
"pregunta": "Clientes cero durante el primer trimestre",
|
| 731 |
+
"query": "SELECT COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND strftime('%m', \"Fecha\") BETWEEN '01' AND '03'\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('2025-03-31', '-27 day')\n);"
|
| 732 |
+
},
|
| 733 |
+
{
|
| 734 |
+
"pregunta": "Dame la cantidad de clientes cero en el segundo trimestre",
|
| 735 |
+
"query": "SELECT COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND strftime('%m', \"Fecha\") BETWEEN '04' AND '06'\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('2025-06-30', '-27 day')\n);"
|
| 736 |
+
},
|
| 737 |
+
{
|
| 738 |
+
"pregunta": "Número de clientes cero del tercer trimestre",
|
| 739 |
+
"query": "SELECT COUNT(DISTINCT \"Razon Social\") AS clientes_cero\nFROM \"{table_name}\"\nWHERE \"Razon Social\" IS NOT NULL\nAND strftime('%m', \"Fecha\") BETWEEN '07' AND '09'\nAND \"Razon Social\" NOT IN (\n SELECT DISTINCT \"Razon Social\"\n FROM \"{table_name}\"\n WHERE DATE(\"Fecha\") > DATE('2025-09-30', '-27 day')\n);"
|
| 740 |
+
}
|
| 741 |
+
]
|
| 742 |
+
}
|
| 743 |
}
|
mojica_agent.py
CHANGED
|
@@ -68,7 +68,7 @@ class MojicaAgent:
|
|
| 68 |
return schema
|
| 69 |
|
| 70 |
def _generate_sql_prompt(self, question: str) -> str:
|
| 71 |
-
memory_context = self.memory.get_context()
|
| 72 |
table_name = self.schema["table_name"]
|
| 73 |
|
| 74 |
# 1. Detectar tipo de pregunta
|
|
|
|
| 68 |
return schema
|
| 69 |
|
| 70 |
def _generate_sql_prompt(self, question: str) -> str:
|
| 71 |
+
memory_context = self.memory.get_context(question)
|
| 72 |
table_name = self.schema["table_name"]
|
| 73 |
|
| 74 |
# 1. Detectar tipo de pregunta
|