Skip to content

Tag: sql

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 …

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…