When I have an SQL query with a GROUP BY clause, It is often very useful to see some of the un-grouped values for easier debugging. My question is, how can I select a string that will be composed of the un-grouped values. For example, in the following code: I would like to have a way to select a string
Tag: sql
Count Number of Columns In Hive
I am looking for a way to count the number of columns in a table in Hive. I know the following code works in Microsoft SQL Server. Is there a Hive equivalent? SELECT COUNT(*), FROM …
t-sql string unique ID (Northwind database)
I’ve been trying to get this right for some time now with no use. I have a table in mssql database and I want to insert new row using stored procedure The problem is CustomerID field which contains unique string for each record (ALFKI, BERGS, BERGS, etc.) I want to make a stored procedure which will ins…
How to export all data from table to an insertable sql format?
I have a Table (call it A_table) in a database (call it A_db) in Microsoft SQL Server Management Studio, and there are 10 rows. I have another database (call it B_db), and it has a Table (call it B_table), which has the same column settings as A_table has. But the B_table is empty. What I want: Copy every row…
DB agnostic SQL for CURRENT_TIMESTAMP
I’m currently using Oracle, but most of the SQL is db agnostic. One exception is CURRENT_TIMESTAMP which fails in MSSQL. Is is possible to move to a more portable syntax for this too? Answer According to their documentation the following vendors support CURRENT_TIMESTAMP. Oracle Postgresql MySQL SQL Ser…
Postgres time with time zone equality
I’m having some trouble with time with time zone equalities in Postgres. timestamp with time zone equality works how I would expect it to, where if the times are the same after normalizing the …
Why does Spring’s JDBC Templates doesn’t use the tables default value
I have a table in MYSQL and I am using JDBC Templates to do an insert into that table. One of the columns has a default value, and I am not specifying it in the Map<String, Object> parameters map. I am getting an exception Column ‘colName’ cannot be null. Can anyone explain this please? Than…
mysql selecting multiple rows that match array of ids
First of all: SELECT `key`, `value` FROM settings WHERE `key` = :base_url OR `key` = :google_analytics OR `key` = :site_domain Is this correct way of selecting multiple rows? Or is there a …
Searching for a specific text value in a column in SQLite3
Suppose I have a table named ‘Customer’ with many columns and I want to display all customers who’s name ends with ‘Thomas'(Lastname = ‘Thomas’). The following query shows an empty result(no rows). Also it didn’t show any error. While executing the following query giv…
Self-Referencing Data Object in CoreData
I’m making the mental switch from a lifetime of SQL to CoreData and it’s not without a few hiccups. The thing that’s kicking me at the moment is creating a self-referencing object. Allow me to explain….