select data from a table if a column is logged with specific data

  • Hi Experts,

    How can i select data from a table if the data logged into a status column(varchar) shows as "Total Completed is greater than 1"

    For Eg:

    Date Status

    2013-03-13 12:30 Total Completed =4 /*select this*/

    2013-03-13 12:00 Total Completed =0

    Thanks in advance

  • You might be looking for something like this.

    SELECT *

    FROM( VALUES

    (CAST( '20130313 12:30' AS DATETIME), 'Total Completed =4'), /*select this*/

    (CAST( '20130313 12:00' AS DATETIME), 'Total Pending =5'),

    (CAST( '20130313 12:00' AS DATETIME), 'Total Completed =0'))x( Date, Status)

    WHERE Status LIKE 'Total Completed =%'

    AND SUBSTRING( Status, CHARINDEX('Total Completed =', Status) + 17, 20) > 1

    However, this seems like a very bad design for the data, try changing it.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply