The query: Returns n records in Postgresql: I just want to retrieve the number of records returned: 6. I used a subquery to achieve what I want, but this doesn’t seem optimum: How would I get the number of records in this context right in PostgreSQL? Answer I think you just need COUNT(DISTINCT post_id) …
Insert multiple rows into single column
I’m new to SQL, (using SQL 2008 R2) and I am having trouble inserting multiple rows into a single column. I have a table named Data and this is what I am trying That code was taken from this question, but it, like many other examples I have found on the web uses 2 columns, I just want to use
How to use an ALIAS in a PostgreSQL ORDER BY clause?
I have the following query: SELECT title, (stock_one + stock_two) AS global_stock FROM product ORDER BY global_stock = 0, title; Running it in PostgreSQL 8.1.23 i get this …
Inserting data into a temporary table
After having created a temporary table and declaring the data types like so; How do I then insert the relevant data which is already held on a physical table within the database? Answer
ASP.NET Web API – Entity Framework – 500 Internal Server Error On .Include(param => param.field)
I am currently working on a Web API project with a Database-First method using Entity Framework (which I know is not the most stable of platforms yet), but I am running into something very strange. …
Refactor a PL/pgSQL function to return the output of various SELECT queries
I wrote a function that outputs a PostgreSQL SELECT query well formed in text form. Now I don’t want to output a text anymore, but actually run the generated SELECT statement against the database and …
PL/pgSQL SELECT into an array
Here’s my function declaration and part of the body: I want team_ids to be an array of ints that I can then use in the UPDATE statement. This function give me errors like this: Answer Faster and simpler with a FROM clause in your UPDATE statement: That aside, while operating with an array, the WHERE cla…
FULL OUTER JOIN vs. FULL JOIN
Just playing around with queries and examples to get a better understanding of joins. I’m noticing that in SQL Server 2008, the following two queries give the same results: Are these performing exactly the same action to produce the same results, or would I run into different results in a more complicat…
SQL select elements where sum of field is less than N
Given that I’ve got a table with the following, very simple content: I would like to select N messages, which sum of verbosity is lower than Y (for testing purposes let’s say it should be 70, then correct results will be messages with id 1,2,3). It’s really important to me, that solution sho…
Java socket client/server
Hi i am trying to get some data about a socket client connecting to a mutltythreaded server process in the same machine. The server thread is triggered correctly and the client ip is retreived ok, but i cant seem to be able to send a string through the connection. THE CLIENT THE SERVER THREAD The line sent th…