0

I have a sql table that I need to extract certain data from. For example: enter image description here

This is an example of my sql table and I would need to pull Monday's reds for a live tile for my application. And so on, I might need to pull Tuesday's reds or Tuesday's yellows.

Is there a query that can help me achieve this?

CSharpDev4Evr
  • 535
  • 1
  • 11
  • 35

2 Answers2

1

This is a basic query to do what you want, if I understand you correctly. I'm assuming that the table headers are the column names.

Get monday's reds:

select [monday] from table where [key] = 'Reds'

Get tuesday's reds:

select [tuesday] from table where [key] = 'Reds'
HaukurHaf
  • 13,522
  • 5
  • 44
  • 59
  • thank you for the response. I tried the query and I am getting errors. I write SELECT [Monday] FROM SUMMARY WHERE [Key] = 'Reds' and get an error saying there is an error near the table name. not sure what I am doing wrong. – CSharpDev4Evr Nov 08 '13 at 03:31
  • Which DBMS are you using? Microsoft SQL Server? – HaukurHaf Nov 08 '13 at 08:50
1

For monday's reds:

select Monday from SUMMARY where Key LIKE 'Reds' //Can also match wildcards, Slower

For tuesday's reds:

select Tuesday from SUMMARY where Key = 'Reds'  //Preferred , Faster 

*Assuming SUMMARY is your tablename as per your comments.
Both ways work.
See the difference between LIKE and = here : Use '=' or LIKE to compare strings in SQL?
Try them here : http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all

Community
  • 1
  • 1
Sahil Sareen
  • 1,813
  • 3
  • 25
  • 40