I was wondering why this SQL script SELECT category, avg(valuation) FROM startups group by 1; Gives me the same output like this one: SELECT category, valuation FROM startups group by 1; And why is …
Tag: sql
How to accurately pull minimum date of each time a payment method was changed
I need to get the minimum date for each time a payment method changes between the method id, account number, or routing number. I’m bouncing between a cursor and between windows functions. Doing the method below seems to work fine, but when i use this method with a larger dataset, with different pay ids…
Storing struct_time in SQL
Some code I am writing in Python takes in a date from a server in the struct_time format (with the 9 args). How can I store this date in an SQL database, and be able to read back this date as a …
Filtering multiple XML nodes using XPath in PostgreSQL
There is an XML with the structure: – Item – Documents – Document – Records – Record – Category – Code – Value And here is the SQL query that …
Is it possible to select all dishes that contain only ingredients A and B in one query?
I know you could achieve this by getting all dishes that contain A and B and then checking every dish in the results with a second query that counts how many ingredients each dish has. Then, if the …
MySql Group By Count item count Distinct
I have a table looks like Here user id 1 exist in level 1 and level 2 Now when we count group by level then in counting we want ignore user_id 1 from level 1 cause it exist another group. we want to consider only one group existing and higher group. I have done only group count but cant understand
Conditionally convert a decimal value to integer
It is showing a result like this But I want result like this when type is 1 then result should be in integer format: on else condition (@Type rather than 1) I want result like this I have tried this query Answer This will work for you. When @type is 1, the result will be 10 for both values. Otherwise
Filtering SQL results by date
Here is my query for a maintenance dates list. The idea is.. Everyday the server will email customers to let them know which checkdates are coming, based on the days notice that is set for that type of check. (see image) Currently it is showing all checkdates. All i need to do is filter the list so it only sh…
Storing unique images in table
I’ve inherited a database which contains .png images which have been converted byte[] and finally ToBase64String and saved in a table with many duplicate images. I want to clean this up create a new table with unique images but the original tables have no primary key related to the image. I’ve com…
Teradata – How to understand data distribution?
I’ve been looking everywhere how I can improve my Teradata views performance by choosing the right primary index in my tables. I have found multiple answers pointing to the same thing, by using this query to see how data is distributed through the AMPs : I get that I need to have an even distribution, b…