[Solved] What is the maximum number of rows you can have in a single table database on the Heroku free plan (MongoDB/PostgreSQL)?

As you can read on the website you linked, a Free PostgreSQL database is limited to 10K (ten thousand) rows. The free “Sandbox” MongoDB option has no document limit, but a size limit of 496 MB. A single MongoDB document can be anywhere between a few bytes and 16MB. 2 solved What is the maximum … Read more

[Solved] SQL Query to Transpose Column Counts to Row Counts

These type of queries are easier to make with an aim of GROUP BY, like this: Select case when profile.foo ~* ‘5.0.2195’ then ‘Win2k’ when profile.foo ~* ‘5.1.2600’ then ‘WinXP’ when profile.foo ~* ‘5.2.3790’ then ‘W2k3’ when (profile.foo ~* ‘6.0.6000’ or profile.foo ~* ‘6.0.6001’ or profile.foo ~* ‘6.0.6002’) then ‘Vista’ when (profile.foo ~* ‘6.1.7600’ or … Read more

[Solved] Storing JSON Array of Arrays in PostgreSql

First statement returns two rows, one for each array. select jsonb_array_elements(msg->’root’) as el from js Then returns each individual values as text. with aa as ( select jsonb_array_elements(msg->’root’) as el from js ) select jsonb_array_elements(el)->>’cid’ as cid, jsonb_array_elements(el)->>’Display’ as Display, jsonb_array_elements(el)->>’FName’ as FName, jsonb_array_elements(el)->>’LName’ as LName from aa; This returns 3rd element of 2nd array … Read more

[Solved] Inserting data into the PostgreSQL from Java Servlet

Your error is on line 73: birthyear = Integer.parseInt(request.getParameter(“birthyear”)); I’m guessing by your code that the form in the doGet function is the form posting the data you want to store in your database. Your form doesn’t contain a birthyear field. Its absence makes request.getParameter(“birthyear”) return null, which causes a NullPointerException when trying to parse … Read more

[Solved] Prevent SQL Injection In This PHP Code

You can ask the database to secure your table and column names, using quote_ident(), before you create the query you want to execute. You need something like this: <?php $table=”table name”; // unsafe $column = ‘column name’; // unsafe $result = pg_query_params($connection, ‘SELECT quote_ident(CAST($1 AS text)), quote_ident(CAST($2 AS text));’, array($table, $column) ); $table = pg_fetch_result($result, … Read more

[Solved] Generate month data series with null months included?

You can generate all starts of months with generate_series(), then bring the table with a left join: select to_char(d.start_date, ‘mon’) as month, extract(month from d.start_date) as month_num, sum(cost_planned) filter (where t.aasm_state in (‘open’, ‘planned’ ) ) as planned, sum(cost_actual) filter (where t.aasm_state=”closed”) as actual from generate_series(‘2020-01-01’::date, ‘2020-12-01’::date, ‘1 month’) d(start_date) left join activity_tasks t on … Read more

[Solved] If two Table’s data are independant, but they have relationship (one Main, another Sub). What is the best way to link them?

Well you are on your with the last comment creating a Foreign Key. So we have a relationship between Customers and Contacts. However the outstanding question becomes what type is Customer:Contact relationship? One-to-One (1:1) -> Each Customer has one contact and a Contact is for one customer. One-to-Many (1:M) -> Each Customer has many contacts … Read more

[Solved] I need to convert a Postgres specific query to SQL Server (T-SQL)

On SQL-Server use CHARINDEX CHARINDEX ( expressionToFind , expressionToSearch [ , start_location ] ) DECLARE @CAMPO30 varchar(64) = ‘2,663.25’; SELECT CASE WHEN CHARINDEX(‘.’, @CAMPO30) > 1 THEN CAST(REPLACE(REPLACE(@CAMPO30,’.’,”),’,’,’.’) AS FLOAT) ELSE CAST(REPLACE(@CAMPO30,’,’,’.’) AS FLOAT) END AS CAMPO30 GO | CAMPO30 | | ——: | | 2.66325 | dbfiddle here 1 solved I need to convert … Read more

[Solved] List ocurrences in column – SQL

Based upon your question, it is a simple select distinct and then an order by SELECT distinct(Column_Name) FROM Table_name ORDER BY Column_Name DESC Or SELECT distinct(Column_Name) FROM Table_name ORDER BY Column_Name Depending on the Sort order that you want 4 solved List ocurrences in column – SQL