I’m using pyodbc to query to an SQL Server database import datetime import pyodbc conn = pyodbc.connect(“Driver={SQL Server};Server=’dbserver’,Database=’db’, …
Tag: sql
How to Select and Order By columns not in Groupy By SQL statement – Oracle
I have the following statement: There exists some extra columns in table Positions that I want as output for “display data” but I don’t want in the group by statement. These are Site, Desk Final output would have the following columns: Ideally I’d want the data sorted like: How to achi…
Null Calculation With SQL Select Statement
I have Following Table Input Output ——————————— 12.22 2.22 If I pass Following Sql Statement: Select Input,Output,Balance=sum(Input – …
CASE Statement in SQL
just a curious question. I have written following code using CASE statement but I don’t have data so I am not sure if my logic is correct. All I am doing is I am applying length check on each field …
trim left characters in sql server?
I want to write a sql statement to trim a string ‘Hello’ from the string “Hello World’. Please suggest. Answer
How to select only the first rows for each unique value of a column?
Let’s say I have a table of customer addresses: In the table, one customer like John Smith can have multiple addresses. I need the SELECT query for this table to return only first row found where there are duplicates in ‘CName’. For this table it should return all rows except the 3rd (or 1st…
SQL Query with ORDER BY
I have a table in my SQL database that looks like: id type radius ————————- 1 type1 0.25 2 type2 0.59 3 type1 0.26 4 type1 0.78 5 type3 …
sql query: if any of the columns have even one word mentioned in a given array of words, select that entire row
I have the following sql query: select distinct * from tableName where contains ( (column1, column2, column3), ‘default’ ) This works fine. Instead of looking at just one keyword ‘default’ is it …
MYSQL – count number of rows in each table
I would like to know how many rows are in each table in my database. I’ve come so far as to having However i would need to do that on each and every table – and there are a lot. What would me the best way to get a print-out with the table name and it’s row count? Answer I
GROUP BY – do not group NULL
I’m trying to figure out a way to return results by using the group by function. GROUP BY is working as expected, but my question is: Is it possible to have a group by ignoring the NULL field. So that it does not group NULLs together because I still need all the rows where the specified field is NULL. S…