To find the data from same table using nested query

I have created a table employee(ename,post,salary). Here i need to find all the employees who work in the same post as Arjun(ename). select a.ename(select b.post from employee b where b.ename like A%n) from employee a What is wrong with my code above View More Answer And Comment : Stackoverflow Consider making a subquery that yields a […]

Getting the current number of connections in a PostgreSQL DB

Which of the following two is better? select numbackends from pg_stat_database; select count(*) from pg_stat_activity; View More Answer And Comment : Stackoverflow From looking at the source code, it seems like the pg_stat_database query gives you the number of connections to the current database for all users. On the other hand, the pg_stat_activity query gives the […]

Retrieve data using select query with null Foreign key value

I have a 2 tables with name Vendor and VendorType . Structure are given CREATE TABLE XCodesSCMERP.dbo.Vendor ( VendorID INT IDENTITY, VendorTypeID INT NULL, VendorName VARCHAR(200) NULL, VendorCompany VARCHAR(200) NULL, FirstName VARCHAR(100) NULL, LastName VARCHAR(100) NULL, Contact VARCHAR(100) NULL, Phone VARCHAR(100) NULL, AltContact VARCHAR(100) NULL, Email VARCHAR(50) NULL, AddressBilledFrom VARCHAR(50) NULL, AddressShippedFrom VARCHAR(50) NULL, VendorNotes […]

Why doesnt this ActiveRecord SQL != query do the opposite of the equivalent = query?

I have the following piece of AR/SQL code returning the following value: Post.joins(:comments).uniq.count # => 20 When I refine it as below, I get the reduced value I would expect: Post.joins(:comments).uniq.where(comments.user_id = ?, user.id).count # => 9 So when I run the same code but with the match negated, I would expect the to get […]

How to Post a SQL String With Quotes?

This seems like it would be a question that has been answered a million times before, but searching for a bit only brought up replacing single quotes with double quotes. The problem is that I have a file with a huge number of single quotes. Is there any way to insert a string as is, […]

await ExecuteNonQueryAsync() still blocks my UI

I find that my C# app UI hangs when calling an async method, I cannot figure out why. private async void selectCSVFileButton_Click(object sender, EventArgs e) { var results = await ntz.getProductNames(); } public async Task<List<string>> getProductNames() { string fmt = DRIVER={{NetezzaSQL}};SERVER={0};PORT={1};DATABASE={2};UID={3};PWD={4};; ntz = new OdbcConnection(string.Format(fmt, server, port, db, user, password)); await ntz.OpenAsync(); […]

Alternative to an SQL Update inside a Loop

Im trying to check two columns in a database (start_date and end_date). If the end_date is greater than the start_date, then I wish to update a record. Is there a better way to do this other than to have an UPDATE SQL query inside the loop? $current_date = time(); echo current_date . $current_date .<br>; while […]

Basic Access Query Sum across fields

I am still a bit of a beginner to Access. I am tracking inventory of medical supplies. I have the tables divided by month that they are inventoried. I would like to Query a Query to sum all of the categories for every month. I am starting with two months to see if I can […]